2016-05-24 114 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);