你好我创建了片段@ + id / activity_fragment__eventi__aggiunti,其中有一个recycleview @ + id / reciclerView_eventi_aggiunti,当我的实例片段我把cardview的列表放在@ + id / reciclerView_eventi_aggiunti中时,这个片段:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_fragment__eventi__aggiunti"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.fra87.eudroid.fragment.Fragment_Eventi_Aggiunti">
<android.support.v7.widget.RecyclerView
android:id="@+id/reciclerView_eventi_aggiunti"
android:scrollbars="vertical"
android:layout_marginTop="20dp"
android:layout_marginBottom="100dp"
android:layout_width="320dp"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
我想把这个片段放在这个布局的relativelayout @ + id / prova中:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_lista__eventi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:scrollbars="vertical"
tools:context="com.example.fra87.eudroid.activity_class.Lista_Eventi">
<SearchView
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="10dp"
android:queryHint="Evento"
android:id="@+id/cercaEvento"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/reciclerView_eventi"
android:scrollbars="vertical"
android:layout_below="@+id/cercaEvento"
android:layout_marginTop="20dp"
android:layout_marginBottom="100dp"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_alignLeft="@id/cercaEvento"
android:layout_alignRight="@id/cercaEvento" >
</android.support.v7.widget.RecyclerView>
<RelativeLayout
android:layout_width="320dp"
android:layout_height="match_parent"
android:id="@+id/prova">
</RelativeLayout>
<Button
android:text="Salva"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:id="@+id/salva_eventi"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/reciclerView_eventi"
android:layout_alignEnd="@+id/reciclerView_eventi" />
</RelativeLayout>
我想在relativelayout @ + id / prova中填充片段,但我希望relativelayout在@ + id / reciclerView_eventi及以上按钮@ + id / salva_eventi 我该怎么做?
答案 0 :(得分:0)
我认为你可以简单地为RecyclerView使用适配器。 无需为列表的每个元素创建片段。