0

我有一个带有列表的 ListFragment,没有单击。但是可以识别长点击。

        ListView listView = getListView();

        listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                      int position, long id) {
                Log.i(null, "single click does NOT work.");
            }
        });

 // contextual action bar (CAB).
        listView.setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view,
                  int position, long id) {
                Log.i(null, "does work.");
            }
        });
4

2 回答 2

1

我有一个类似的问题,并通过在创建时和滚动后使列表视图的视图无效来解决

listView.setOnScrollListener(new OnScrollListener() {
    public void onScrollStateChanged(AbsListView view, int scrollState) {
        if ( scrollState == OnScrollListener.SCROLL_STATE_IDLE )
        {
          listView.invalidateViews();
        }

    }

    @Override
    public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {}
});

我希望这有帮助

于 2012-06-05T15:08:51.193 回答
0

使您的活动从Activity而不是 ListActivity 或类似的东西扩展;)

于 2012-06-05T14:59:28.140 回答