I created a new app relying on the default "Master Detail Flow" template, chosen in the "New Project..." dialog of Android Studio. Then I adapted the application to fit my needs and my data. Works like a charm on handhelds and tablets.
The only thing I want to achive ist to autoselect the first item in the list, showing the detail view and setting the list item as selected.
In the "ItemListFragment" I called the "onListItemClick(...)" method in the overwritten "onStart()" method. This had following behaviours:
- When rotating the device, the first item in the list gets selected (not the previously selected one)
- The list item does not get marked as selected in the list
Could someone point me in the right direction on how to achieve this. Because I only want this behaviour in "Tablet-Mode" I guess I have to put it into the ItemListActivity?
Thanks
EDIT: This is my "onCreate" method of the "ItemListActivity"
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_list);
if (findViewById(R.id.item_detail_container) != null) {
mTwoPane = true;
((ItemListFragment) getFragmentManager()
.findFragmentById(R.id.item_list))
.setActivateOnItemClick(true);
}
}