Im trying to add recycler view on dialog but dialog not showing anything...I have added cards on recycler view and want to display recycler view on dialog
android.support.v7.app.AlertDialog.Builder dialog = new android.support.v7.app.AlertDialog.Builder(getContext());
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.last_transaction_report, null);
recyclerView = (RecyclerView) dialogView.findViewById(R.id.transactio_rep_recyclerView);
dialog.setView(dialogView);
AlertDialog alertDialog = dialog.create();
// alertDialog.setContentView(dialogView);
alertDialog.show();
adapter = new TransactionReportCardAdapter(listTransactionDetails, this);
recyclerView.setAdapter(adapter);
Assuming R.layout.dialog_layout
is a layout with recyclerview
Dialog dialog = new Dialog(context, R.style.DialogSlideAnim);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
dialog.setContentView(R.layout.dialog_layout);
dialog.setCanceledOnTouchOutside(true);
dialog.setCancelable(true);
dialog.show();
RecyclerView rvTest = (RecyclerView) dialog.findViewById(R.id.rvTest);
rvTest.setHasFixedSize(true);
rvTest.setLayoutManager(new LinearLayoutManager(context));
rvTest.addItemDecoration(new SimpleDividerItemDecoration(context, R.drawable.divider));
DataDialogAdapter rvAdapter = new DataDialogAdapter(context, rvTestList);
rvTest.setAdapter(rvAdapter);
styles.xml
<style name="DialogSlideAnim" parent="@android:style/Theme.Dialog">
<item name="android:windowAnimationStyle">@style/DialogAnimation</item>
</style>
<style name="DialogAnimation">
<item name="android:windowEnterAnimation">@anim/slide_up_dialog</item>
<item name="android:windowExitAnimation">@anim/slide_down_dialog</item>
</style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With