एप्लिकेशन में मैं एक Listactivity जो TextView और बटन (हटाना लेबल) के साथ एक एडाप्टर है की है। अब मैं संबंधित बटन क्लिक आइटम को हटाना चाहता हूं। कृपया कोड की जांच करें और सुझाव दें ???? `ListView के अंदर बटन पर ऑनक्लिक लिस्टनर() कैसे सेट करें?
public class MySimpleArrayAdapter extends ArrayAdapter<String> implements OnClickListener {
private final Activity context;
private final String[] names;
private Button deleteButton= null;
public MySimpleArrayAdapter(Activity context, String[] names) {
super (context, R.layout.imagelistlayout, names);
this.context = context;
this.names = names;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView = inflater.inflate(R.layout.imagelistlayout, null, true);
deleteButton= (Button)rowView.findViewById(R.id.delete_bn);
deleteButton.setTag(position);
TextView textView = (TextView) rowView.findViewById(R.id.label);
textView.setText(names[position]);
deleteButton.setOnClickListener(this);
return rowView;
}
@Override
public void onClick(View convertView) {
System.out.println(deleteButton.getTag());
}
}`
मुझे पता है कि कैसे मैं आइटम जिसकी बटन क्लिक किया गया है हटा सकते हैं चाहता हूँ।
http://stackoverflow.com/questions/1821871/android-how-to-fire-onlistitemclick-in-l istactivity-साथ-बटन-इन-सूची –
http://www.geekmind.net/2009/11/android-custom-list-item-with-nested.html –