i'ld like to know how i can switch my dialogs layout file without creating a separate one.
I have a custom dialog fragment i use for connecting to bluetooth devices in my app. It pops up a list of devices and i connect to a device of my choosing.
I have two xml layouts i want to use with this dialog fragment: - The first one holds the listview for devices i want to connect to - The other houses and image view
When i connect to a device, i want to switch the layout from the list to the one that houses the imageview. Some where in my code, i have a variable that checks the connection status.
if i'm connected, i switch to the other layout like this:
getDialog().setContentView(R.layout.xml2);
and it works but then when i want to show the dialog again, i get this error.
Attempt to invoke virtual method 'void android.app.Dialog.setContentView(int)' on a null object reference
In my onCreateView method, i'm check my connection state.
if (connected) {
return inflater.inflate(R.layout.xml2, container, false);
} else {
return inflater.inflate(R.layout.xml1, container, false);
}
I know the error has to do with the changing getDialog().setContentView when state changed to connected. I'm thinking about how to revert back to the default view on dismiss so the onCreateView can take effect. If there is another method to doing this, i'ld like to hear about it. Any Ideas?
Thanks in advance...