Context: I want to have a ListView that won't receive focus (for example, won't highlight a row when the user touches it). However, each row widget has its own OnClickListener. Here is what I indicate in the xml layout:
android:choiceMode="none" android:focusableInTouchMode="false" android:focusable="false"
ListView still behaves exactly the same. Can someone explain
TIA.
, . , . , ListView, - int , . , ClickListener. . onListItemClick ListView.
int
onListItemClick
, android:listSelector android:background -, , , .
android:listSelector
android:background
android:listSelector="#8fff" , .
android:listSelector="#8fff"
, , . , .
xml, . , , , .
setContentView...
myListView.setFocusableInTouchMode(false);
, , , .
myListView.setOnFocusChangeListener(new OnFocusChangeListener(){ public void onFocusChange(View v, boolean hasFocus) { v.setBackgroundColor(hasFocus ? Color.GRAY : Color.BLACK); } }); myListView.setClickable(true);
Can't you use the RadioButton, which is selected when the user touches a line in the list?
Below is a snippet of my own code.
// Create an adapter with a simple list item with single choice. adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, categories); // Set the adapter to your list listView.setAdapter(adapter);
Hurrah!
Source: https://habr.com/ru/post/1703610/More articles:What to do with INotifyPropertyChanged when changing the list of child elements - data-bindingHow big is xmonad if I still need my "old" IDE graphics environment? - kdeboost :: thread: Segfault when launching the optimized version - multithreadingHow to create an installation and deployment project that can run any number of times on a machine without the need for removal? - installationare there any ASP.NET with voice recording code examples? - flashhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1703611/can-i-limit-users-to-a-specific-range-and-zoom-level-on-google-maps&usg=ALkJrhjfm4N0MnO2OCIMDKZZIHNndFiRaAuser authenticated but missing Ticket.UserData - c #Lack of Libtool, double building? - autotoolsCPython internal structures - pythonCamel SOAP Method Names - soapAll Articles