I have one custom baseadapter for listView. Now I have buttons on each listView item. I need to disable the button onclick of them. But when I'm clicking on one of the buttons, multiple buttons are disabling on the list. I'm attaching the code .
@Override
public View getView(int arg0, View convertView, ViewGroup arg2) {
// TODO Auto-generated method stub
final int k = arg0;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_view_element, null);
}
TextView name = (TextView)convertView.findViewById(R.id.textView1);
name.setText(arrayList.get(arg0).getName());
TextView phone = (TextView)convertView.findViewById(R.id.textView2);
phone.setText(arrayList.get(arg0).getPhoneNum());
Button request = (Button)convertView.findViewById(R.id.button1);
request.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Update the local database of Request table
databaseHelper.insertRequestTable(new Person(arrayList.get(k).getName(), arrayList.get(k).getPhoneNum()));
((Button)arg0).setEnabled(false);
}
});
return convertView;
}
Please help.