0
我想在SimpleCursorAdapter類中使用listview。我的問題是我無法點擊列表視圖。
我的適配器類是....Android - SimpleCursorAdapter ListView無法點擊
public class ColorAdapter extends SimpleCursorAdapter {
private Context context;
public ColorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) {
super(context, layout, c, from, to);
this.context = context;
}
public int getCount() {
// TODO Auto-generated method stub
return MyArrList.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.event_list, null);
}
TextView tname = (TextView) convertView.findViewById(R.id.ename);
tname.setText(MyArrList.get(position).get("EventName"));
TextView tdetail = (TextView) convertView
.findViewById(R.id.edetail);// ใส่ข้อมูลทีละส่วน
tdetail.setText(MyArrList.get(position).get("EventDetail"));
return convertView;
}
}
在點擊的方法是....
elist.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Intent intent = new Intent(getApplicationContext(),
EventsDetail.class);
String eventName = MyArrList.get(position).get("EventName").toString();
intent.putExtra("EventName", eventName);
startActivity(intent);
}
});
當我點擊列表視圖它沒有發生。有誰能夠幫助我?
謝謝。我現在可以點擊。 – TooKom