当我长时间点击Google TV时,这两种方法都会被调用,但只有在平板电脑上使用相同的代码调用相应的方法。任何想法如何处理onItemLongClick而不触发GoogleTV上的onListItemClick?
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Log.i(DEBUG_TAG, "onListItemClick");
WeatherData.getSingleton(getActivity().getApplication()).setCurrentLocationCode(WeatherData.getSingleton(getActivity().getApplication()).getLocCodes().get(position));
getListView().setItemChecked(position, true);
}
public boolean onItemLongClick(AdapterView<?> l, View v, int pos, long id) {
Log.i(DEBUG_TAG, "onItemLongClick");
if (WeatherData.getSingleton(getActivity().getApplication()).getLocCodes().size() > 1)
showDeleteAlertDialog(pos);
return false;
}
答案 0 :(得分:3)
将onItemLongClick的返回值设置为true,以便它消耗整个操作。像魅力一样工作!