我需要在列表视图中显示我的值,我需要在列表视图中单独执行特定textview的单击
我试过这样的
ListAdapter adapter = new SimpleAdapter(
ViewAppoinmentScreen.this, medicationlist,
R.layout.appoinmentlist, new String[] {
"clinic_name", "id", "app_type",
"app_date", "app_time", "app_desc" },
new int[] { R.id.name, R.id.app_id,
R.id.app_type, R.id.date, R.id.time,
R.id.comments }){
@Override
public View getView (int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = mInflater.inflate(
R.layout.appoinmentlist, parent, false);
ImageView del = (ImageView) rowView
.findViewById(R.id.imageView3);
del.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String id = ((TextView) findViewById(R.id.app_id))
.getText().toString();
Toast.makeText(ViewAppoinmentScreen.this, " Clicked Successfully", Toast.LENGTH_LONG).show();
System.out.println("deleted action"+id);
}
});
return rowView;
}
};
med_list.setAdapter(adapter);
Getview方法正常工作我能看到吐司消息,但我无法看到列表视图中的值。值未设置为适配器。 我做错了什么我不知道?请帮助我。
先谢谢。
答案 0 :(得分:1)
我通过用这样的
替换getView
解决了我的问题
@Override
public View getView (int position, View convertView, ViewGroup parent)
{
View v = super.getView(position, convertView, parent);
ImageView del = (ImageView) v
.findViewById(R.id.imageView3);
del.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(ViewAppoinmentScreen.this,"Deleted",Toast.LENGTH_SHORT).show();
}
});
return v;
}
现在很好。