我使用标签导航创建了两个标签。每个选项卡都有带定制适配器的网格视图我的问题是项目单击网格视图正在使用一个选项卡但在第二个选项卡项单击不工作。你们能告诉我为什么吗?请
第一个标签:此处项目点击工作:
public class MyPictureFragment extends Fragment implements OnItemLongClickListener{
private final static String TAG="MyPictureFragment";
private static SharedPreferences Prefs = null;
private static String prefname = "galleryPrefs";
private GridView gridview=null;
List<PartnerImage_Model> list_images=new ArrayList<PartnerImage_Model>();
TextView textviwe;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.mypictureuploaded, container, false);
gridview=(GridView)view.findViewById(R.id.gridView_pic);
textviwe= (TextView)view.findViewById(R.id.textView);
gridview.setOnItemLongClickListener(this);
return view;
}
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Toast.makeText(getActivity(), "onClick click", Toast.LENGTH_LONG).show();
return false;
}
}
第二个标签代码:
public class MyVideoFragment extends Fragment implements OnItemLongClickListener{
private final static String TAG="MyVideoFragment";
private static SharedPreferences Prefs = null;
private static String prefname = "galleryPrefs";
private GridView gridview=null;
List<PartnerVideo_Model> list_video=new ArrayList<PartnerVideo_Model>();
TextView textviwe;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.myvideouploaded, container, false);
gridview=(GridView)view.findViewById(R.id.gridView_video);
gridview.setOnItemLongClickListener(this);
return view;
}
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Toast.makeText(getActivity(), "onClick click", Toast.LENGTH_LONG).show();
return false;
}
}
答案 0 :(得分:0)
注意:从true
方法返回onItemLongClick
。即。
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Toast.makeText(getActivity(), "onClick click", Toast.LENGTH_LONG).show();
return true;
}
检查here以获取Android文档