onListItemClick and onItemLongClick Google TV

蹲街弑〆低调 提交于 2019-12-08 09:52:28

问题


Both the methods are being called when I do a long click on Google TV, but only the appropriate one is called with the same code on a tablet. Any ideas how to handle onItemLongClick without triggering onListItemClick on GoogleTV?

@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;
    }

回答1:


Set return value of onItemLongClick to true so that it consumes the entire action. Works like a charm!



来源:https://stackoverflow.com/questions/8406181/onlistitemclick-and-onitemlongclick-google-tv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!