长按上ListFragment [英] Long click on ListFragment
本文介绍了长按上ListFragment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正与一个ListFragment并做了onListItemClick。一切工作正常,但现在我想用很长的项目点击(如setOnItemLongClickListener(新OnItemLongClickListener()的一个活动),如何使用这在我的片段?
I'm working with a ListFragment and doing a onListItemClick. Everything works fine, but now I want to use a long Item Click (e.g setOnItemLongClickListener(new OnItemLongClickListener() for an Activity). How can I use this in my fragment?
谢谢!
推荐答案
是,该解决方案张贴TSYNC为我工作。我也曾经遇到了同样的问题,并认为这是不可能的。我尝试了上述建议如下:
Yes, the solution posted by tsync works for me. I too had ran into same problem and considered that this is not possible. I tried the above suggestion as follows:
public class ProjectsFragment extends ListFragment {
@Override
public void onActivityCreated(Bundle savedState) {
super.onActivityCreated(savedState);
getListView().setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
Toast.makeText(getActivity(), "On long click listener", Toast.LENGTH_LONG).show();
return true;
}
});
和它的工作!
这篇关于长按上ListFragment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文