答案 0 :(得分:1)
试试这个:
<强> custom_dialog.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<强>活动/ Fragment.java
RecyclerView mRecyclerView;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
LayoutInflater inflater = LayoutInflater.from(context);
View content = inflater.inflate(R.layout.custom_dialog, null);
builder.setView(content);
mRecyclerView = (RecyclerView) content.findViewById(R.id.my_recycler_view);
答案 1 :(得分:1)
您应该扩展DialogFragment并创建自定义对话框,其中包含回收站视图。
布局: - fragment_dialog.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
您的自定义对话框: - MyDialogFragment
public class MyDialogFragment extends DialogFragment {
private RecyclerView mRecyclerView;
// this method create view for your Dialog
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//inflate layout with recycler view
View v = inflater.inflate(R.layout.fragment_dialog, container, false);
mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_view);
//setadapter
//get your recycler view and populate it.
return v;
}
}