2016-01-07 1 views
0

i ont vue sur la liste à l'intérieur d'un recyclerview comme ceci: enter image description herelistview intérieur recyclerView Ne faites défiler

et défilement du travail ne marche pas listview sur cette mise en œuvre.

mon but est de cliquer sur le bouton listview pour afficher et masquer. le principal Ui est sur viewpager pour onglet

public class tabOne extends Fragment { 

    RecyclerView myTabRecycler; 
    adapterMainList adapter; 

    public tabOne() { 

    } 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 
     View v = inflater.inflate(R.layout.tab_one, container, false); 

     myTabRecycler = (RecyclerView) v.findViewById(R.id.tabRC); 
     myTabRecycler.setHasFixedSize(true); 
     LinearLayoutManager llm = new LinearLayoutManager(G.context); 
     llm.setOrientation(LinearLayoutManager.VERTICAL); 
     myTabRecycler.setLayoutManager(llm); 
     adapter = new adapterMainList(Utiles.getSampleCat()); 
     myTabRecycler.setAdapter(adapter); 
     Utiles.Log(Utiles.getSampleCat().size()); 
     myTabRecycler.startNestedScroll(2); 

     return v; 
    } 
    } 

l'adaptateur pour recyclerView:

public class adapterMainList extends RecyclerView.Adapter<adapterMainList.CatViewHolder> { 

    private List<retroCategory> cats; 

    public adapterMainList(List<retroCategory> catList) { 
     this.cats = catList; 

    } 


    @Override 
    public int getItemCount() { 
     return cats.size(); 
    } 


    @Override 
    public void onBindViewHolder(final CatViewHolder catViewHolder, final int position) { 


     final retroCategory cat = cats.get(position); 
     Utiles.Log("BindNow"); 
    } 

    @Override 
    public CatViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { 
     View itemView = LayoutInflater. 
       from(viewGroup.getContext()). 
       inflate(R.layout.adapter_item_category, viewGroup, false); 
     return new CatViewHolder(itemView); 
    } 

    public static class CatViewHolder extends RecyclerView.ViewHolder { 

     protected ListView vList; 
     protected ImageView vImg; 


     public CatViewHolder(View v) { 
      super(v); 

      vList = (ListView) v.findViewById(R.id.adapter_item_list); 
      vImg = (ImageView) v.findViewById(R.id.adapter_item_img); 

     } 


    } 
    } 

l'élément Ui:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/tools" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/adapter_item_cat_title" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="right|center_vertical|center_horizontal" 
     android:padding="16dp" 
     android:textAppearance="@style/TextAppearance.AppCompat.Title" 
     android:textColor="@color/black" /> 

    <android.support.v7.widget.CardView 
     android:id="@+id/card_view" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp" 
     app:cardUseCompatPadding="true" 
     card_view:cardBackgroundColor="@color/white" 
     card_view:cardElevation="4dp"> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal"> 

       <Button 
         android:id="@+id/adapter_item_num_session" 
         android:layout_width="0dp" 
         android:layout_weight="1" 
         android:layout_height="wrap_content" 
         android:padding="4dp" 
         android:gravity="left|bottom" 
         android:textColor="@color/colorPrimaryDark" /> 

       <ImageView 
        android:id="@+id/adapter_item_img" 
        android:layout_width="0dp" 
        android:layout_height="80dp" 
        android:layout_weight="0.3" 
        android:scaleType="fitXY" 
        android:src="@drawable/sherlock" /> 


      </LinearLayout> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

    <ListView 
     android:id="@+id/adapter_item_list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="8dp" 
     android:paddingRight="8dp"> 

    </ListView> 




</LinearLayout> 

et sur l'application runnig quand je veux faire défiler la listview , RecyclerView Scrolled au lieu de cela ... comment puis-je résoudre ce ?? merci

désolé pour le mauvais anglais

Répondre

2

Vous ne doivent pas utiliser unListView dans une autre vue scrollable. Dans ce cas, vous utilisez un ListView dans un RecyclerView.

Utilisez un LinearLayout au lieu de ListView. Quelque chose comme:

public class MyListLayout extends LinearLayout implements 
     View.OnClickListener { 

    private Adapter list; 
    private View.OnClickListener mListener; 

    public MyListLayout(Context context) { 
     super(context); 
    } 

    public MyListLayout(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 

    } 

    public MyListLayout(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    @Override 
    public void onClick(View v) { 
     if (mListener!=null) 
      mListener.onClick(v); 
    } 

    public void setList(Adapter list) { 
     this.list = list; 

     //Popolute list 
     if (this.list!=null){ 
      for (int i=0;i<this.list.getCount();i++){ 
       View item= list.getView(i, null,null); 
       this.addView(item); 
      } 
     } 

    } 

    public void setmListener(View.OnClickListener mListener) { 
     this.mListener = mListener; 
    } 
}