关于GridView的滑动问题
发布时间:2018-02-01 来源:查字典编辑
摘要:我在一个Fragment里面嵌套了一个FrameLayout,然后里面是有两个GridView,但是我写完后发现,这两个GridView都不...
我在一个Fragment里面嵌套了一个FrameLayout,然后里面是有两个GridView,但是我写完后发现,这两个GridView都不会上下滑动了,数量是绝对足够用来下拉的,以下是代码: 两个显示的GridView我单独试过了,数据还有下拉什么都是正常,但是放到这里面就出问题了,显示没问题,就是没有下拉效果了,新人不怎么会写,求大佬们帮帮忙,先在这里谢过了
,还有就是想问一下 fragmentManager = getSupportFragmentManager();和 fragmentManager = getFragmentManager();区别是什么。这俩都是用来干什么的
public class FenleiFragmentTest extends Fragment { private FragmentManager fragmentManager; private FragmentTransaction transaction; private RadioGroup radioGroup; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View view = inflater.inflate(R.layout.fenlei_fragment_test, null); fragmentManager = getFragmentManager(); radioGroup = (RadioGroup)view.findViewById(R.id.fenlei_test_radioGroup); //设置默认打开的页面 ((RadioButton)radioGroup.findViewById(R.id.fenlei_test_radioGroup_btn1)).setChecked(true); transaction = fragmentManager.beginTransaction(); Fragment fragment = new FenleiGridFragment(); transaction.replace(R.id.fenlei_test_frame_layout, fragment); transaction.commit(); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.fenlei_test_radioGroup_btn1: transaction = fragmentManager.beginTransaction(); Fragment fenleiFragment = new FenleiGridFragment(); transaction.replace(R.id.fenlei_test_frame_layout, fenleiFragment); transaction.commit(); break; case R.id.fenlei_test_radioGroup_btn2: transaction=fragmentManager.beginTransaction(); Fragment fenleiFragement1=new FenleiGridFragmenta(); transaction.replace(R.id.fenlei_test_frame_layout,fenleiFragement1); transaction.commit(); break; } } }); return view; } }
回复讨论(解决方案)
问题找到了,原因是用了自定义的GridView,导致不可拉动,本来自定义的是为了解决嵌套后的问题的,结果弄巧成拙
我的分啊啊啊啊