I read everything and understand your statements, I see that you have ever done programming, but apparently just starting with Android, I already did a lot to build systems, so I completely understood the concept of software availability it looks like this:
void run(){ object.setup(); while(true){ otherObject.run(); } }
But there is one fundamental flaw in your logic of your question:
Android programming is another paradigm of programming from C ++ and computer programming, and you should understand its specific paradigm instead of assuming what is good practice from other paradigms.
Quote from you: create and show a new ListView (for example) on my main layout. I want to get the width and height of the newly created Listview, for what I have to override onWindowFocusChanged() create and show a new ListView (for example) on my main layout. I want to get the width and height of the newly created Listview, for what I have to override onWindowFocusChanged() .
From this, I see that you are really trying to make Android stuff in a way that is not recommended in the context of Android. You can easily implement ListView from the XML layout of setContentView(int) and use Activity onCreate to instantiate any stream infrastructure (AsyncTaskLoader) to load data in the background and deliver it back to the user interface.
This does not mean that all your code will be dumped in one file, which makes it useless. This small example that I will tell you can be done with an Activity that implements loader callbacks, a separate class with a loader, a separate class with data loading work, a separate class with a data adapter, activity is just the central part that organizes and manage these classes at the right moment in the life cycle and in no case need to call onWindowFocusChanged() and have well-organized code.
Also, please refer to CommonsWare, as it is usually expertly written and fixed.
Budius
source share