简体   繁体   中英

ScrollView in Android Studio while using a pull up refresh

So I have a refresh swipe down function, that when you pull from down anywhere on the screen it refreshes...However I don't want this,I have a listview, that is pumped by a JSon object..this part is not important, I got all of the json working...the part that I can't figure out is how to make it so when I pull up on the Listview i go up on the listview,right now when i pull up the whole page refreshes. My XML for that page ...

 <in.srain.cube.views.ptr.PtrClassicFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/ptr_care" > <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.fzhang.nhchecklist.ResidentCareActivity"> <TextView android:id="@+id/care_summary_textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:textColor="@android:color/black" tools:layout_constraintTop_creator="1" android:layout_marginStart="2dp" android:layout_marginTop="20dp" android:layout_marginBottom="20dp" tools:layout_constraintLeft_creator="1" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" android:layout_marginLeft="2dp" /> <ListView android:id="@+id/care_info_listview" android:fadeScrollbars="false" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" android:layout_marginTop="10dp" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/care_summary_textview" /> </android.support.constraint.ConstraintLayout> </in.srain.cube.views.ptr.PtrClassicFrameLayout> 

My java

  mPtrFrame=(PtrClassicFrameLayout)findViewById(R.id.ptr_care); mPtrFrame.setLastUpdateTimeRelateObject(this); mPtrFrame.setPtrHandler(new PtrHandler() { @Override public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) { return PtrDefaultHandler.checkContentCanBePulledDown(frame, content, header); } @Override public void onRefreshBegin(PtrFrameLayout frame) { updateDataWithPTR(); } }); 

Anyone have any good ideas, there is also a refresh and onResume...Though that doesnt really matter (if it does please correct me) Thanks for the help

To achieve pull to refresh behavior that works on top of your list (it will work when you do a pull gesture on care_summary_textview) and not on list itself use this:

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.fzhang.nhchecklist.ResidentCareActivity">

   <in.srain.cube.views.ptr.PtrClassicFrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/ptr_care"
        tools:layout_constraintTop_creator="1"
        android:layout_marginStart="2dp"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="20dp"
        tools:layout_constraintLeft_creator="1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="2dp">

       <TextView
           android:id="@+id/care_summary_textview"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:textSize="20sp"
           android:textColor="@android:color/black"/>

   </in.srain.cube.views.ptr.PtrClassicFrameLayout>

    <ListView
        android:id="@+id/care_info_listview"
        android:fadeScrollbars="false"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginTop="10dp"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/ptr_care" />


</android.support.constraint.ConstraintLayout>

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