我用标签导航创建了两个标签。每个选项卡都有带有自定义适配器的网格视图。我的问题是网格视图的项目单击正在使用一个选项卡,但在第二个选项卡项目中单击不起作用。你们能建议我为什么吗?请
第一个标签:这里项目点击工作:
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;
}
}