This post is about a popular, well-discussed topic- Handle Screen Orientations. Even though it's much talked about, I could hardly draw a working solution for the app which forces me write here.
So, the app is basically made of tabs using TabHost. Each tab is an activity group. The app primarily fetches data from a web service using AsyncTask. Each child activity is attached to an AsyncTask which holds a UI handler object- the one that displays all UI related actions such as displaying alert messages and attaching listView adapters.
For instance, invoking an asynctask from an activity is as follows.
UIHandler handler = new UIHandler(this, getParent()) //parent context of the tab
CustomAsyncTask taskRunner = new CustomAsyncTask(handler);
taskRunner.execute(params);
I tried using save and restore instance state which obviously didn't work. I find it confusing to use configurations in my scenario.
Hope I did explain the stand. Could you suggest a way out?
NOTE:
Let me know if I should provide more details to support the scene.
Current way of handling:
I have a single layout for most of the screens. It works well with a single line on the manifest file.
android:configChanges="keyboard|keyboardHidden|orientation"
But now, I got two screens having two layouts, one for each orientation.
EDIT
I have a ListView that uses custom adapter. Fetching data from the server, the UI handler properly loads the listView.
In the Custom adapter's getView(), I use a layout xml for the row layout.
public View getView(int position, View convertView, ViewGroup parent) {
convertView = mInflater.inflate(R.layout.custom_fullpicturerow, null);
}
On orientation change, how do I change the above layout and loads the new one?