0

I have a ViewPager with a SectionPagerAdapter handling Fragments.

The Fragment has the following Layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/tvemptyview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/card_bg"
        android:text="@string/no_trans"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <ListView
        android:id="@+id/transactionlist"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:divider="@null"
        android:dividerHeight="0dp" >
    </ListView>

    <RelativeLayout
        android:id="@+id/rLayout1"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:background="@drawable/footer_shadow"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/tvMonth"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_centerVertical="true"
            android:layout_toRightOf="@id/btn_dateback"
            android:text="test"
            android:textAppearance="?android:attr/textAppearanceMedium" />

    </RelativeLayout>

</RelativeLayout>

I'm trying to catch a swipe gesture (left or right) on the TextView tvMonth but I have absolutely no idea how to dispatch the Event from the ViewPager down to the TextView itself. The Fragments just keep on scrolling and thats it.

I can attach an OnTouchListener to the TextView and the recognition works pretty fine but the tabs are changing anyway.

How can i solve this problem?

MKAI
  • 64
  • 6
  • You could try writing a custom implementation of the viewpager. Check this question and answer for more information. http://stackoverflow.com/questions/16342630/how-to-disable-viewpager-adapter-on-touching-specific-views – Joel Dean Aug 31 '13 at 22:25

1 Answers1

0

You should set either an onClickListener or touchListener on the textView its self. Then the touch event will be automatically dispatched to the TextView.

greenspand
  • 749
  • 2
  • 8
  • 15