2017-02-09 1 views
0

Recyclerviewの中にNestedScrollViewの2つがあります。第2のRecyclerviewSwipeRefreshLayoutです。私は両方のリサイクラーのための1つのスクロールを設定しようとするが、私の解決策は動作しませんでした。 2つのリサイクルスクロールと別に私は解決策がありません、私の助けてください。前もって感謝します。私のコード2つのリサイクラを1つにスクロール

<android.support.v4.widget.NestedScrollView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fillViewport="true"> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/noFriendsTitle" 
     android:layout_marginTop="@dimen/marginTop" 
     android:layout_centerHorizontal="true" 
     android:visibility="gone" 
     android:text="@string/no_friends_title"/> 
    <ProgressBar 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/progressBarGetFriends" 
     android:layout_centerInParent="true"/> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/mainFriendsRelative" 
     android:paddingTop="@dimen/marginTopSmall" 
     android:paddingBottom="@dimen/marginTopSmall" 
     android:visibility="invisible"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginStart="@dimen/paddingStart" 
      android:id="@+id/lastConversationTitle" 
      android:text="@string/friends_important_title"/> 
     <android.support.v7.widget.RecyclerView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/lastChatFriendsRecyclerView" 
      android:layout_below="@+id/lastConversationTitle" 
      android:layout_marginTop="@dimen/marginTopSmall"/> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginStart="@dimen/paddingStart" 
      android:layout_below="@+id/lastChatFriendsRecyclerView" 
      android:layout_marginTop="@dimen/marginTopSmall" 
      android:id="@+id/allFriendsTitle" 
      android:text="@string/friends_all"/> 
     <android.support.v4.widget.SwipeRefreshLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/friendSwipeToRefresh" 
      android:layout_below="@+id/allFriendsTitle" 
      android:layout_marginTop="@dimen/marginTopSmall"> 
      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/friendsRecyclerView" 
       android:scrollbars="vertical"/> 
     </android.support.v4.widget.SwipeRefreshLayout> 
    </RelativeLayout> 
</RelativeLayout> 

マイフラグメントコード

private void setLastConversationFriendsRecycler(RecyclerView lastConversationRecyclerView, List<Edge<Friends>> friends){ 
    lastConversationList.addAll(friends); 
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); 
    lastConversationRecyclerView.setHasFixedSize(true); 
    lastConversationRecyclerView.setLayoutManager(layoutManager); 
    lastConversationAdapter = new FriendsAdapter(getActivity(), lastConversationList, lastConversationRecyclerView); 
    lastConversationRecyclerView.setAdapter(lastConversationAdapter); 
} 

private void setFriendsRecycler(RecyclerView friendsRecyclerView, List<Edge<Friends>> friends){ 
    friendsList.addAll(friends); 
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); 
    friendsRecyclerView.setHasFixedSize(true); 
    friendsRecyclerView.setLayoutManager(layoutManager); 
    friendsAdapter = new FriendsAdapter(getActivity(), friendsList, friendsRecyclerView); 
    friendsAdapter.setOnLoadMoreListener(friendsListener); 
    friendsRecyclerView.setAdapter(friendsAdapter); 
} 

私はまたsetNestedScrollingEnabledと異なる組み合わせを試してみたが、結果は同じでした。

+0

あなたはあなたのRecyclerViewsの両方のために(偽)setNestedScrollingEnabled設定されている意味しますか? –

+0

はい、両方のリサイクラーにfalseを設定すると、スクロールが無効になり、何もスクロールできなくなります –

+0

まだ回答はありますか? –

答えて

3

解決策が見つかりました。私のコードに何が間違っていますか。それは仕事のコードです、多分誰かが同じ問題を抱えています。

<android.support.v4.widget.SwipeRefreshLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:id="@+id/friendSwipeToRefresh"> 
<android.support.v4.widget.NestedScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical" 
    android:fillViewport="true"> 
    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/noFriendsTitle" 
      android:layout_marginTop="@dimen/marginTop" 
      android:layout_centerHorizontal="true" 
      android:visibility="gone" 
      android:text="@string/no_friends_title"/> 
     <ProgressBar 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/progressBarGetFriends" 
      android:layout_centerInParent="true"/> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/mainFriendsRelative" 
      android:paddingTop="@dimen/marginTopSmall" 
      android:paddingBottom="@dimen/marginTopSmall" 
      android:visibility="invisible"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginStart="@dimen/paddingStart" 
       android:id="@+id/lastConversationTitle" 
       android:text="@string/friends_important_title"/> 
      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/lastChatFriendsRecyclerView" 
       android:layout_below="@+id/lastConversationTitle" 
       android:layout_marginTop="@dimen/marginTopSmall"/> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginStart="@dimen/paddingStart" 
       android:layout_below="@+id/lastChatFriendsRecyclerView" 
       android:layout_marginTop="@dimen/marginTopSmall" 
       android:id="@+id/allFriendsTitle" 
       android:text="@string/friends_all"/> 
      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:id="@+id/friendsRecyclerView" 
       android:layout_marginTop="@dimen/marginTopSmall" 
       android:layout_below="@+id/allFriendsTitle" /> 
     </RelativeLayout> 
    </RelativeLayout> 
</android.support.v4.widget.NestedScrollView> 

断片

private void setLastConversationFriendsRecycler(RecyclerView lastConversationRecyclerView, List<Edge<Friends>> friends){ 
    lastConversationList.addAll(friends); 
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); 
    lastConversationRecyclerView.setHasFixedSize(true); 
    lastConversationRecyclerView.setNestedScrollingEnabled(false); 
    lastConversationRecyclerView.setLayoutManager(layoutManager); 
    lastConversationAdapter = new FriendsAdapter(getActivity(), lastConversationList, lastConversationRecyclerView); 
    lastConversationRecyclerView.setAdapter(lastConversationAdapter); 
} 

private void setFriendsRecycler(RecyclerView friendsRecyclerView, List<Edge<Friends>> friends){ 
    friendsList.addAll(friends); 
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); 
    friendsRecyclerView.setHasFixedSize(true); 
    friendsRecyclerView.setNestedScrollingEnabled(false); 
    friendsRecyclerView.setLayoutManager(layoutManager); 
    friendsAdapter = new FriendsAdapter(getActivity(), friendsList, friendsRecyclerView); 
    friendsAdapter.setOnLoadMoreListener(friendsListener); 
    friendsRecyclerView.setAdapter(friendsAdapter); 
} 
関連する問題