Android ListView List Item Element Programmatically

I know that they asked me, but I have not yet found the answer (the newcomer to Android is so sorry for ignorance)

launching my application Activity has EditText (called a search engine), ListView (notation) and Spinner (types)

I use EditText as a search query, I need to pass a string using custom editing to make the search more flexible. After that, I compare this with the closest approximation that I find in the โ€œnotationโ€ and

designations.setSelection(j); 

As expected, this sets the desired element to the beginning of the notation. But I can not find a way to highlight it with the code.

NOW, I know that if the device is in touch, highlighting the selected item will not happen. So the last 4 lines of my onTextChanged search query:

  designations.setFocusable(true); designations.setFocusableInTouchMode(true); if (match==true) designations.setSelection(j); if (st.length()==0) designations.setSelection(0); 

to no avail.

now I have no code in the afterTextChanged search box (Editable s);

can anyone give me the key to this?

Regards ~ Dk

+6
android listview highlight listviewitem
source share
2 answers

check requestFocus () and possibly requestChildFocus ()

+3
source share

Have you tried to set the actual View for selection?

 designations.setSelection(j); designations.getSelectedView().setSelected(true); 
+2
source share

All Articles