简体   繁体   中英

ViewPager overlap HorizontalListview in android

I am using viewpager and fragments and display different section. At bottom, I have used Horizontallistview from A to Z and if i click display respective data with letter indicates.

Problem: When I am trying to scrolling bottom horizontal view pager execute(slow horizonalistview) and goes to next page but my intention is scolling horizontallistview. In here, why not horizontallistview smoothly scrolling.

在此处输入图片说明

I used viewpager in MainActivity;

<android.support.v4.view.ViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rlv2"
        android:layout_marginTop="-40dp" >

        <android.support.v4.view.PagerTabStrip
            android:id="@+id/pager_title_strip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="4dp"
            android:paddingTop="4dp"
            android:textColor="@color/black"
            android:textStyle="bold" />
    </android.support.v4.view.ViewPager>

and bottom horizontalistview putting in fragment activity.

<com.devsmart.android.ui.HorizontalListView
        android:id="@+id/hlistview"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:background="@drawable/textviewborder"
        android:focusableInTouchMode="true"
        android:overScrollMode="always" />

So, How to solve this problem. I want to smoothly horizontal list view.

Simple, you can just put in your oncreate and make OnTouchListener.

hListView.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
    // TODO Auto-generated method stub
    hListView.requestDisallowInterceptTouchEvent(true);
    return false;
    }
});

Hope this will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM