0
我有一个ListView
包含RelativeLayout
-Items与Text
,Buttons
和东西。我想对用户点击按钮作出反应,但由于某种原因,onItemClick
未被解雇Android - Listview忽略TouchEvent
您是否有任何想法可能导致这种情况?
storeItems = (ListView) findViewById(R.id.st_storeitems);
storeItems.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3)
{
Toast.makeText(getApplicationContext(), "test", Toast.LENGTH_LONG).show();
if(v.getId() == R.id.csi_buy) {
// Some Code
}
}
});
也可以使用android:descendantFocusability =“blocksDescendants”到xml中的根元素 – Raghunandan
@Raghunandan我从来没有使用它。任何副作用? – Blackbelt
不认为有任何副作用。 http://developer.android.com/reference/android/view/ViewGroup.html#attr_android:descendantFocusability – Raghunandan