你应该去创建像使用 BaseAdpter 这样的客户适配器,在这里传递你的列表并根据位置设置该列表到 Textview,在这里你可以设置 onClick 事件,你也可以像 ex (1) 一样创建基本适配器
public class GridAdpter extends BaseAdapter
{
List<String> checkednamelist;
public GridAdpter(Context c, List<String> myitem) {
this.checkednamelist =myitem
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//Here change with yur row xml file name and 3 textview control id name
View grid;
if (convertView == null) {
grid = layoutInflater.inflate(R.layout.row_grid, null);
} else {
grid = convertView;
}
TextView textView2 = (TextView) grid.findViewById(R.id.txtlable2);
textView.setText(checkednamelist.get(position);
textView2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// do here as per your require
}
});
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return myitem.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return myitem.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public List<String> mycheckeditem() {
return checkednamelist;
}
}
// 最后用你的列表视图设置这个适配器