0
私は1つの主要なアクティビティといくつかのフラグメントを持つアプリケーションを持っていますが、すべてのフラグメントはリストフラグメントですが、そのうちのいくつかではカスタムアクションを持つFloatingActionButtonを追加する必要があります。そのリストのために自動生成されたアダプタを保存したいと思います。 FloatingActionButtonをxml list disapperに直接追加するとどうすればボタンを追加できますか?フラグメントリストのリストビューの下にフローティングボタンを追加します
これは私のフラグメントのXMLコード
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list"
android:name="it.ivannotarstefano.cojule.activity.PlayerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:layoutManager="LinearLayoutManager"
tools:context="it.ivannotarstefano.cojule.activity.PlayerFragment"
tools:listitem="@layout/fragment_player" >
</android.support.v7.widget.RecyclerView>
と私は思い
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list"
android:name="it.ivannotarstefano.cojule.activity.PlayerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
app:layoutManager="LinearLayoutManager"
tools:context="it.ivannotarstefano.cojule.activity.PlayerFragment"
tools:listitem="@layout/fragment_player" >
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="10dp"
android:clickable="true"
android:focusable="true"
android:src="@drawable/ic_add_black_24dp"
app:backgroundTint="#fff700" />
</android.support.v7.widget.RecyclerView>