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();
我在对话框中有一个回收站视图,我想在这里获取它的ID 我怎么知道如何为这个回收站充气布局我只需要知道如何从对话框视图中访问这个视图
答案 0 :(得分:3)
请试试这个 -
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);
答案 1 :(得分:1)
您应该可以使用dialog.findViewById(R.id.whatever);