Search code examples
androiddialogfragment

Modfiying inflated inflated view in a dialogfragment after calling show()


Let's say you have a dialogfragment with a listView. The title of the dialog is a custom view which is inflated in onCreateDialog(). Is it possible to toggle visibility of the inflated view when the list item is clicked.


Solution

  • In the onCreateDialog() function, you can hold the dialog view which referencing to title view which you want to toggle on. On click event of listview.

    lv.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
    //Toggle your title here
        }
    });