Makahleh
Makahleh

Reputation: 11

i want to create a recyclerview inside a dialog box

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

i have a recycler view inside my dialog box and i want to get the id of it here how and i know how i can inflate a layout for this recycler i just need to know how i can access this view from my dialog box view

Upvotes: 1

Views: 4637

Answers (2)

Atahar Hossain
Atahar Hossain

Reputation: 336

please try this -

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

Upvotes: 3

craya
craya

Reputation: 653

You should be able to access your dialog's views using dialog.findViewById(R.id.whatever);

Upvotes: 1

Related Questions