I found a similar question about scrolling through a list and clicking a button, but that didn't help me. My problem:
I have a listview with custom strings. I have two different list states; the switch between states is a button at the bottom of the screen. The second state has delete buttons on each line. When I click the delete button on a specific row, that row is deleted from the database and the list is updated. Everything works fine, except that I need to double-click the "Delete" button to make it work. Below is my click processing code. flag == 1 is the second state of the list.
public void onItemClick(AdapterView<?> parent, View v, int position, long id) { View main = parent.getChildAt(position); TextView delete = (TextView)main.findViewById(R.id.delete_button); if(flag==0){ switchToItemsView(id); } if(flag==1){ delete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDbHelper.deleteList(id); updateListView(); }}); } }
I tried to set the focusableInTouchMode parent view attribute to false, as suggested in another post, but that didn't help.
If you can help me, I will be grateful
Thanks in advance.
source share