Some element is stealing the focus, and the clicks on my listview don’t register.
Can someone suggest a way to find which?
Here is how the app works:
Activity > inner custom View > onTouch > AlertDialog.builder.setView(custom ListView)
I mistakenly thought I needed two choices, and used with total success the same setup, using .setPositiveButton and .setNegativeButton on the builder before. But I need more choices, therefore a ListView.
Here are the relevant lines from the ListView:
final ListView lv = new ListView(this);
lv.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, names) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) { convertView = new TextView(GameActivity.this); }
((TextView)convertView).setText((String)getItem(position));
return convertView;
}
public long getItemId(int position) { return position; }
public String getItem(int position) { return names[position]; }
public int getCount() { return names.length; }
});
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
///////Nothing happens, never called
}
});
I read twenty or thirty stack overflow posts, it almost always has something to do with a view stealing the focus.
Which view is stealing the focus, how can I debug this?
Thanks! 🙂
The answer is in Sam’s comment: it simply worked, and I wasn’t dismiss()ing the dialog.