2016-05-24 94 views
0
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(); 

我已经在我的对话框回收者视图内recyclerview,我想在这里得到它的ID 如何,我知道我可以吹这个回收的布局我只需要知道我可以从我的对话框视图访问此视图我想创建一个对话框

回答

1

你应该能够使用dialog.findViewById(R.id.whatever);

1

请尝试用它来访问你的对话框的意见 -

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);