Android layout resource problem
i want to get views from layout defined in my layout folder but i get null pointer exception, i know that before i use findViewById i have to have the layout somewhere used in any activity so it gets initialized, is the开发者_开发技巧re anyway to get views from layout that has not been used in any activity cause i got one activity that uses layout which i dynamically change and in that layout i remove all of it's child views and apply one of the three layouts that i have aside as potential layouts to fill in the default activity's layout..
I need this to make dialogs cause i have one dialog that has one layout which is transparent and has attached onTouchListener and when i click the layout the dialog dismisses, now my idea is to get other layouts which have size defined and then fill in that layout in the default transparent layout of my custom dialog, and do this with any layout i could image so i can make dialogs from all the layouts i want..
Thanks, if you need anymore info about my idea please write me this is important to me!
You can use getResources() from the context to retrieve resources individually:
getResources().getLayout(id);
More info here: Accessing Resources
精彩评论