2

I have two fragment in my application under one activity. My problem is when I moved to second fragment using gridview click on 1st fragment, my 1st fragment still getting the touch onscroll event from 2nd fragment scrolling and touch. Here is the code snippet:

1st Fragment:

   gridview.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    FragmentRadioListByCategory nextFrag = new FragmentRadioListByCategory();
                    FragmentManager manager = getFragmentManager();
                    FragmentTransaction transaction = manager.beginTransaction().replace(R.id.relativeLayoutCategory, nextFrag);
                    transaction.addToBackStack(null);
                    transaction.commit();
                }
            });

gridView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState){
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem,
                                 int visibleItemCount, int totalItemCount) {

            }
        });

2nd Fragment:

listView.setOnScrollListener(new AbsListView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState){

            }
        });

And 2nd fragment XML file:

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipeRefreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_color"
    android:clickable="true">

    <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="3dp"
            android:clickable="true">

                <ListView
                    android:id="@+id/list_radio"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:divider="@null">
                </ListView>


    </android.support.v4.widget.SwipeRefreshLayout>

How can I solve the issue of prevention touch event on 1st fragment. I am also using the android:clickable="true" in XML but its not working here.

0xAliHn
  • 18,390
  • 23
  • 91
  • 111

0 Answers0