android - 我想在对话框中创建一个 recyclerview

标签 android

 case R.id.menuAbout:
            Dialog dialog = new Dialog(MainActivity.this);
            dialog.setTitle("About Us");
            dialog.setContentView(R.layout.dialog_layout);
            recyclerView =(RecyclerView)findViewById(R.layout.dialog_layout);
            layoutManager = new LinearLayoutManager(this);
            recyclerView.setLayoutManager(layoutManager);
            recyclerView.setHasFixedSize(true);
            dialog.show();

我的对话框中有一个回收站 View ,我想在这里获取它的 ID 我如何知道如何为这个回收器扩充布局我只需要知道如何从我的对话框 View 访问这个 View

最佳答案

请试试这个 -

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);
    View convertView = LayoutInflater.from(context).inflate(R.layout.member_list_dialog, null);
    alertDialog.setView(convertView);
    alertDialog.setTitle(context.getResources().getString(R.string.memberList));
    Dialog dialog = alertDialog.create();
    RecyclerView rv = (RecyclerView) convertView.findViewById(R.id.rv_member_list);
    rv.setLayoutManager(new LinearLayoutManager(context));
    rv.setHasFixedSize(true);

关于android - 我想在对话框中创建一个 recyclerview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37425512/

相关文章:

Android:如何将 AsyncTaskLoader 添加到此 RecyclerView

android - onClick 不适用于自定义对话框

android - 由于AndroidManifest.xml,无法构建应用

android - 聚类在 Android 版谷歌地图中不起作用。我究竟做错了什么?

安卓源码 : Why is it shown as folder in some projects and package in other?

带有 Jquery Mobile 的 Javascript 不适用于 Android 2.3 及更低版本

Android 有没有简单的方法来备份您的 android 项目?

android - Android Marshmallow libsqlite.so 源码调用ftruncate时如何使用ftruncate64?

android - Google 日历崩溃,因为我添加了一个结束时间早于开始时间的事件

java - 在日历应用程序中如何在微调器中列出同步帐户名称时避免重复