谁能告诉我为什么这在我的 LG400f 触摸手机上不起作用,但在模拟器中单击鼠标却可以正常工作?
代码
ListView listView = (ListView) findViewById(R.id.listContactsList);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_contacts, R.id.listContactsView, values);
listView.setAdapter(adapter);
listView.setClickable(true);
listView.setFocusable(true);
listView.setFocusableInTouchMode(true);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Object selection = (Object) parent.getItemAtPosition(position);
Toast.makeText(getApplicationContext(), selection.toString(), Toast.LENGTH_LONG).show();
// Toast is triggered with mouse click in emulator but not touch in phone
XML
<ListView
android:id="@+id/listContactsList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
tools:context=".ListContacts" />