just wanted to ask about this since I found it really weird and I can't tell why this was happening. Well I think the code will explain it all and I just wanted to know why does this happen.
record_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
SELECTED_ITEM_ON_LIST = (String)(record_list.getItemAtPosition(i));
Log.v("Selected adapterView", String.valueOf(adapterView.getSelectedItem()));
Log.v("Selected adapterView", String.valueOf(adapterView.getFocusedChild()));
Log.v("Selected item position", String.valueOf(record_list.getSelectedItem()));
Log.v("Selected item position", String.valueOf(record_list.getSelectedItemPosition()));
Log.v("adapterView", String.valueOf(adapterView.getCount()));
Log.v("View", String.valueOf(view.isSelected()));
Log.v("recordList", String.valueOf(record_list.getCount()));
Log.v("Selected item", SELECTED_ITEM_ON_LIST);
}
});
and the logs:
on first click for awesome2:
V/Selected adapterView: null
06-07 09:45:12.398 8488-8488/com.test.testaudio V/Selected adapterView: null
06-07 09:45:12.408 8488-8488/com.test.testaudio V/Selected item position: null
06-07 09:45:12.408 8488-8488/com.test.testaudio V/Selected item position: -1
06-07 09:45:12.408 8488-8488/com.test.testaudio V/adapterView: 14
06-07 09:45:12.408 8488-8488/com.test.testaudio V/View: false
06-07 09:45:12.408 8488-8488/com.test.testaudio V/recordList: 14
06-07 09:45:12.408 8488-8488/com.test.testaudio V/Selected item: Awesome2
second click for awesome4:
V/Selected adapterView: null
06-07 09:45:37.099 8488-8488/com.test.testaudio V/Selected adapterView: null
06-07 09:45:37.108 8488-8488/com.test.testaudio V/Selected item position: null
06-07 09:45:37.108 8488-8488/com.test.testaudio V/Selected item position: -1
06-07 09:45:37.108 8488-8488/com.test.testaudio V/adapterView: 14
06-07 09:45:37.108 8488-8488/com.test.testaudio V/View: false
06-07 09:45:37.108 8488-8488/com.test.testaudio V/recordList: 14
06-07 09:45:37.108 8488-8488/com.test.testaudio V/Selected item: Awesome4
as you can see the item position is always null for selected item and always -1 for selected item position. can anybody tell me why?