issue in Android Fragment : still click on previous fragment

大兔子大兔子 提交于 2019-12-03 02:02:00
Emil Adz

Take a look at this question of mine:

An invisible layout behind the fragment is getting clicked:

What helped me in this case and as the accepted answer states is to add the

android:clickable="true"

property to the top hierarchy ViewGroup of the layout you designed for the fragment on top ( the one that is being clicked through). That way the top fragment intercepts your clicks no matter where they occur (and even if no action is applied to it) and are not being passed to the lower level fragment/activity layout.

Edit YOur code commit line from middle to end

    Fragment fragment = new FragmentContactDetails();
                FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
                transaction.add(((ViewGroup) getView().getParent()).getId(), fragment);


                Bundle args = new Bundle();
                int index = adapter.arrayList.indexOf(adapter.propertyList.get(position));

                args.putInt(Constant.POSITION, index);
                Toast.makeText(getActivity(), "" + index + "----" + adapter.propertyList.get(position).getName(), Toast.LENGTH_LONG).show();
                fragment.setArguments(args);
transaction.addToBackStack(null);
                transaction.commit();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!