Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change app theme from ordinary "Blank Activity" to "Master/Detail Flow"

I have an application that works on the basic theme "Blank Activity" and what i would like to do is to change it to a "Master/Detail Flow" theme. I do know that this will make my application work on android SDK 11 + (android 3.0 Honeycomb +), that is OK with me. The issue is i don't know where to start from, what are the basic steps to make this BIG conversion? I couldn't find any example to help me out with this issue. What should i be looking for. i am sure this has been done, can you at least please give me some pointer on how to do this? my Application is not that complicated it uses activities, async tasks, DB, custom lists,... it is very basic. I use the custom list to display data and when i click on it it displays much more details, so I thought what better way to do this in a more professorial matter than the "Master/Detail Flow". If you have any tutorial regarding the "Master/Detail Flow" that you can hook me up with that might help.

like image 227
Waqleh Avatar asked Aug 25 '13 20:08

Waqleh


3 Answers

I have an application that works on the basic theme "Blank Activity" and what i would like to do is to change it to a Master/Detail Flow" theme.

I think a change of the application flow would be more appropriate then a change of theme. Two obvious questions that would appear are why do you suddenly want to make this change and are sure your app makes sense in a master/detail flow? The answer would most likely be positive but you should answer them nonetheless.

I do know that this will make my application work on android SDK 11 + (android 3.0 Honeycomb +), that is OK with me

I don't see why you're app couldn't run on versions below with the new master/detail stuff.

The issue is i don't know where to start from, what are the basic steps to make this BIG conversion? I couldn't find any example to help me out with this issue. What should i be looking for. i am sure this has been done, can you at least please give me some pointer on how to do this?

You haven't provided details about how is your app implemented. The change would revolve around fragments so a BIG question would be if the current single pane version is built using the fragments framework.

If your app is built using fragments then making the change shouldn't be too hard. You'd need to:

  • establish which parts(fragments) should be combined in an activity(from your old ones) to make the master/detail(when the space would allow it)
  • change the multi pane activity to accommodate the new fragment(s). This should be easy to do but it would depend on the size of the features exposed by each of those fragments.
  • modify the rest of the activities(for when the app will not run in the multi pane mode), this would be small changes as the activities would mainly remain as the current version

If your app isn't built using fragments, then what I said above still applies but you'd need to also actually make the required fragments wrapping whatever functionality your app has. This would most likely result in a big code refactoring.

like image 165
user Avatar answered Sep 30 '22 17:09

user


Here is a tutorial about the Master/Detail template in Android - An Android Master/Detail Flow Tutorial.

As far as I understand your application is up and running - so I'm not sure whether it is worth it to try rewriting it, unless you are experiencing some problems of course. :) In general the master/details flow requires the following steps:

  • Implement a ListFragment showing basic information of your items
  • Implement a Fragment showing detailed information about a particular item
  • Make an xml layout file for large devices (located in layout-sw600dp folder for example). In this layout you have to put both your fragments.
  • Write a general version of this layout file (i.e. file with the same name but located in the layout folder), which contains only the ListFragment.
  • Let your activity handle onItemClick event from the ListFragment. Each time an item is clicked, you have to check if the activity is showing both fragments or only the ListFragment. If both are visible, you have to notify the details fragment that new item is selected so it can show its data. Otherwise you have to create new details fragment (you reuse it of course), pass it some information about the selected item (so it can show the item's data) and replace the ListFragment with the new one.

That a basic overview, but it should be enough to give you some idea about this flow. If you need any more details - just let me know. :)

like image 24
Samuil Yanovski Avatar answered Sep 30 '22 17:09

Samuil Yanovski


Master/detail flow and blank activity is not same as you want to change by only changing app theme or app base theme. It will be better, if you first design master/detail flow template using UI fragments, then according integrate you blank activity with the master template making necessary changes. And for master/detail flow tutorial just google it, you will find lots of example there.

like image 35
Pradip Avatar answered Sep 30 '22 19:09

Pradip