-1

something similar to image that on call of SwipeRefreshLayoutListener my whole layout should go down 我想在調用SwipeRefreshLayout Listener時將整個佈局向下移動?這是東西在Android中possile?? 這是我的整個xml layout.SwipeRefreshLayout包含一個progressbar和FrameLayout,它包含在RelativeLayout.So中,我希望FrameLyout在我呼叫刷新時拉下來。在swipeRefreshLayoutListener上拉下整個佈局android

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:custom="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:orientation="vertical"> 

    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawer_navigation_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <include 
       android:id="@+id/toolbar" 
       layout="@layout/toolbar_layout" /> 

      <android.support.v4.widget.SwipeRefreshLayout 
       android:id="@+id/swipeRefresh" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_below="@id/toolbar"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="vertical"> 

        <ProgressBar 
         android:id="@+id/horizontal_sync_progress" 
         style="@style/Widget.AppCompat.ProgressBar.Horizontal" 
         android:layout_width="match_parent" 
         android:layout_height="1dp" 
         android:background="@color/gradient_bg_end" 
         android:indeterminateDrawable="@drawable/progress_drawable" 
         android:progressDrawable="@drawable/progress_drawable" 
         android:visibility="gone"/> 

        <FrameLayout 
         android:id="@+id/container_frag" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" /> 
       </LinearLayout> 
      </android.support.v4.widget.SwipeRefreshLayout> 
     </RelativeLayout> 

     </android.support.v4.widget.DrawerLayout> 
</LinearLayout> 
+0

您嘗試到現在爲止?請發佈一些代碼 –

+2

你必須在xml文件的頂部設置SwipeRefreshLayout。 –

+0

雅..我會分享我的xml – Divya

回答

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

<android.support.v4.widget.SwipeRefreshLayout 
        android:id="@+id/swp1" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"> 

<-----Your design here------> 

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

</RelativeLayout> 

嘗試。你必須在上面設置你的SwipeRefreshLayout。希望它可以幫助你。如果這不會幫助你問我什麼問題,我會幫你

和我的類代碼低於

mSwipeRefreshLayout1 = (SwipeRefreshLayout) findViewById(R.id.swp1); 
      //set colors if you need 
mSwipeRefreshLayout1.setColorSchemeResources(R.color.colorPrimary, R.color.colorPrimaryDark, R.color.colorPrimaryLight); 
      mSwipeRefreshLayout1.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 
       @Override 
       public void onRefresh() { 
        mSwipeRefreshLayout1.setRefreshing(true); 
        try { 

         //Refresh data 

        } catch (Exception e) { 
         //Toast.makeText(getActivity(), String.valueOf(e.getMessage()), Toast.LENGTH_SHORT).show(); 
         //customtoast.ShowToast(getActivity(), String.valueOf(e.getMessage()), R.layout.red_toast); 
        } 
       } 
      }); 
+0

@Divya這可以幫助你嗎?如果這有助於您將此作爲正確答案,以便其他人從此獲得幫助 –

+0

放慢速度......您剛發佈此答案。 –

+0

@Zaki它不會在swipeRefreshLayoutListener調用時拉下佈局。我想拉下framelayout。怎麼做? – Divya

0

,你可以像這樣的代碼

swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 
     @Override 
     public void onRefresh() { 
      new class(getActivity(), listView, progressBar, mApp.getPreference().getString(Common.u_id, ""), "all", swipe).execute(); 
     } 
    }); 
    return view; 
} 

包括下列代碼您的xml文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    //your xml codes 
    </RelativeLayout> 
</android.support.v4.widget.SwipeRefreshLayout>