Last active
March 13, 2016 05:24
-
-
Save SayChunKim/7a28d7cbae7f69354e73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.data.myapplication; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.BaseAdapter; | |
import android.widget.TextView; | |
import com.example.data.myapplication.R; | |
/** | |
* Created by Data on 13/3/2016. | |
*/ | |
public class myAdapter extends BaseAdapter { | |
private final Context context; | |
private final String[] days, japaneseDays; | |
LayoutInflater mInflater; | |
// private static LayoutInflater inflater = null; | |
public myAdapter(Context ctx, String[] Days, String[] JapaneseDays) { | |
context = ctx; | |
this.days = Days; | |
this.japaneseDays = JapaneseDays; | |
mInflater = ((Activity)context).getLayoutInflater(); | |
} | |
@Override | |
public int getCount() { | |
return days.length; | |
} | |
@Override | |
public Object getItem(int i) { | |
return days[i]; | |
} | |
@Override | |
public long getItemId(int i) { | |
return i; | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
// TODO Auto-generated method stub | |
final ViewHolder vh; | |
vh = new ViewHolder(); | |
if (convertView == null) { | |
convertView = mInflater.inflate(R.layout.my_layout_listitem, parent, false); | |
//inflate custom layout | |
vh.tv1 = (TextView) convertView.findViewById(R.id.textView1); | |
vh.tv2 = (TextView) convertView.findViewById(R.id.textView2); | |
vh.tv1.setText(days[position].toString()); | |
vh.tv2.setText(japaneseDays[position].toString()); | |
} else { | |
convertView.setTag(vh); | |
} | |
return convertView; | |
} | |
class ViewHolder | |
{ | |
TextView tv1,tv2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment