I know that there are many threads with more or less than one topic, but none of them covers my situation:
I populate my ListView with a special CursorAdapter using my own rows. I have two states for a ListView: the first state consists only of texts in rows; the second state has a delete button in each row. Switching between two states is the button at the bottom of the view.
I am trying to achieve: in the first state, when I click on a line, the screen should switch to another view. In the second state, when I click the delete button, the selected row must be deleted from the database, the ListView must be populated, and nothing should happen if I click any other part of the row except the delete button.
I know how to delete an item and refill the ListView, and I know how to switch to another view when I click on a row in the first state; but I could not combine them. I use the following method to get id and line position:
protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id);
I tried using some if statements to get a condition for clicking the delete button or for clicking on a line, but that didn't work.
The first question is obvious: how can I make it work?
The second question: in the second state, when any part of the line is pressed, except for the button of the "Delete" button, it switches to another view. How can I prevent this? I tried to set the .setClickable, .setPressed, .set Selected string attributes to false, but that didn't help.
Thanks for your answers in advance.