Reputation: 1882
I need to dispaly my values in list view and i need to perform a click for particular textview alone in the list view
I have tried like this
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 method is working i can able to see the toast message but i cant able to see the values in my listview. Values are not set to adapter. What mistake i have done i don't know ?Please help me.
Thanks in Advance.
Upvotes: 1
Views: 52
Reputation: 1882
I have solved my issuse by replace the getView
by something like this
@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;
}
Now its fine.
Upvotes: 1