我正在使用带有列表的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.");
}
});
答案 0 :(得分:1)
我遇到了类似的问题,并通过在创建时和滚动
之后使listview的视图无效来解决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) {}
});
我希望这会有所帮助
答案 1 :(得分:0)
让您的活动延伸至活动,而非ListActivity或类似内容;)