The problem is if click on first button then the twelfth button also working this error only in mobile if run on emulator the list show all elements and run perfectly.but in mobile list view shows 10 items and need to scroll down to see more`public class MyCustomAdapter extends BaseAdapter implements ListAdapter { private ArrayList list = new ArrayList(); private Context context;
public MyCustomAdapter(ArrayList<String> list, Context context) {
this.list = list;
this.context = context;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int pos) {
return list.get(pos);
}
@Override
public long getItemId(int pos) {
return 0; //list.get(pos).getId();
//just return 0 if your list items do not have an Id variable.
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.list, null);
}
//Handle TextView and display string from your list
TextView listItemText = (TextView)view.findViewById(R.id.name);
listItemText.setText(list.get(position));
//Handle buttons and add onClickListeners
final Button deleteBtn = (Button)view.findViewById(R.id.present);
final Button addBtn = (Button)view.findViewById(R.id.absent);
deleteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//do something
// list.remove(position); //or some other task
Toast.makeText(context,"hello",Toast.LENGTH_SHORT).show();
deleteBtn.setBackgroundColor(Color.GREEN);
addBtn.setEnabled(false);
// notifyDataSetChanged();
}
});
addBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//do something
addBtn.setBackgroundColor(Color.GREEN);
deleteBtn.setEnabled(false);
// notifyDataSetChanged();
}
});
return view;
}
}`
this is list item adding
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
str = sp1.getSelectedItem().toString();
//handle listview and assign adapter
if(str.equals("3rd year")) {
Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT).show();
for(int i=0;i<15;i++)
{
list3.add("Item"+i);
}
}
ListView lView = (ListView) findViewById(R.id.listView);
lView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lView.setAdapter(adapter);
}

boolean flagto identify in which item you have clicked with id or some thing - Sree