2017-06-13 7 views
0

私はリサイクルビューを含むフラグメントを持っており、すべてのアイテムを押すと、すべてのスワイプでフラグメントを表示するビューページャを保持している別のフラグメントが表示されます。リサイクルビューアイテムを押した後に最初にフラグメントに入ると、ページャーは表示されません。 2回目は 、残りの時間は期待どおりのデータが表示されます。View Pagerは初めて初めての場合のみ

コード:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 


     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/lineItems" 
      style="@style/TitleTextView"/> 

     <android.support.v4.view.ViewPager 
      android:id="@+id/CardTablepager" 
      android:layout_width="match_parent" 
      android:layout_alignParentBottom="true" 
      android:layout_height="wrap_content"/> 

    </LinearLayout> 

コンテンツの断片(ビューページャは、このフラグメントをスワイプ)::ノー助けを借りて、いくつかの記事を読んで

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/poMainlayout"> 
     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      style="@style/CardViewStyle" 
      android:layout_margin="8dp" 
      > 
      <android.support.v7.widget.RecyclerView 
       android:id="@+id/poLineItemsTable" 
       android:layout_marginLeft="5dp" 
       android:layout_marginRight="5dp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:scrollbarStyle="outsideInset" 
       /> 
     </android.support.v7.widget.CardView> 

</LinearLayout> 

Android Viewpager display wrong data on first load

主なフラグメントは、ビューページャ保持しています

また、メインのfragmeからアダプターを無効にしようとしましたヘルプなしのNT:

@Override 
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 
     super.onViewCreated(view, savedInstanceState); 
     viewPager.getAdapter().notifyDataSetChanged();   

    } 

どのようなアイデアですか?

+0

あなたが入れて持っていけません'Recyclerview'は' ScrollView'の中に 'ScrollingView'と' NestedScrollingChild'を実装しています – eLemEnt

+0

私は質問を更新したので、問題ではなく水平と垂直のスクロールでリサイクルビューを作成したいと考えました。 – BoazGarty

答えて

1

ただ、あなたのアダプタがviewpagerへの変更以下

@Override 
public void onCreateView(View view, @Nullable Bundle savedInstanceState) { 
    super.onViewCreated(view, savedInstanceState); 
    viewPager.getAdapter().notifyDataSetChanged();   

} 
+0

あなたのビューページをどこで定義しましたか?フラグメント全体を入れることが可能です – Meikiem

+0

私はあなたの提案を試みました。ビューページビューはまだここで膨張していないので、うまくいきません。 – BoazGarty

+0

あなたの最初の断片について私に教えてください。あなたのビューページャーをどこで定義しましたか? – Meikiem

0

てみonViewCreatedないonCreateView

<android.support.v4.view.ViewPager 
     android:id="@+id/CardTablepager" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:minHeight="600dp" 
     android:layout_weight="1" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

そしてRecyclerViewセット次のプロパティの通知:

recyclerView.setHasFixedSize(true); 
    recyclerView.setNestedScrollingEnabled(false); 
+0

ニースは試してみましたが、やはり同じ動作です。 – BoazGarty

関連する問題