H
H
h1_0ne2020-04-20 21:42:15
Android
h1_0ne, 2020-04-20 21:42:15

How to create and set an adapter for AlertDialog?

Good afternoon. There is a layout that I want to show as a dialog. It has some elements like TextView, ImageView. How can I put data in these elements? I assume that you need to transfer the adapter there. So that's how to create it and how to pass it when creating a dialog?

val dialog = LayoutInflater.from(context).inflate(R.layout.news_dialog, null)

            val builder = AlertDialog.Builder(context).setView(dialog)
            
            builder.show()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Zakharov, 2020-04-20
@h1_0ne

It has some elements like TextView, ImageView

How many of these elements?
You can get to any dialog element through the dialog variable and the findViewById method.
You can also extend the Dialog or DialogFragment class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question