How to change the theme of the application from the usual "Void" to "Master / Detailed flow"

I have an application that is working on the basic topic "Empty Action", and I would like to do this to change it to the theme "Master / Detailed Stream". I know that this will make my application work with Android SDK 11 + (android 3.0 Honeycomb +), and everything is fine with me. The problem is that I don’t know where to start, what are the main steps for this BIG conversion? I could not find any example to help me solve this problem. What should I look for. I am sure it was done, can you at least give me some pointer on how to do this? my application is not so complicated that it uses actions, asynchronization tasks, DB, user lists ... it's very simple. I use a custom list to display the data, and when I click on it, it displays a lot more details, so I thought that a better way to do this in a more professional question than "Master / Detail Flow". If you have a Master / Detail Flow tutorial that you can link to, this may help.

+6
source share
5 answers

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

I think changing the application flow would be more appropriate than changing the theme. There were two obvious questions: why do you suddenly want to make this change and are sure that your application makes sense in the master / detail stream? The answer is likely to be yes, but you must answer them nonetheless.

I know that this will make my application work with Android SDK 11 + (Android 3.0 Honeycomb +), everything is fine with me

I do not understand why you cannot run applications in versions below using the new master / detail file.

The problem is that I don’t know where to start, what are the main steps to make this a BIG conversion? I could not find any example to help me with this problem. What should I look for. I am sure that this was done, can you at least give me some pointer on how to do this?

You did not provide information about how your application is implemented. The change will revolve around fragments, so the big question will be if the current version with one panel is built using the framework.

If your application is built using fragments, then the change should not be too complicated. You need:

  • set which parts (fragments) should be combined into action (from your old ones) to make a master / part (when space allows this)
  • change the action of the multilevel panel to accommodate the new fragment (s). This should be easy to do, but it will depend on the size of the functions displayed by each of these fragments.
  • change the rest of the actions (when the application will not work in the multi-level panel mode), this will be small changes, since the actions will mainly remain in the current version

If your application is not built using fragments, then what I said above still applies, but you will also need to make the necessary fragments that will have all the functions of your application. This is likely to lead to refactoring of large code.

+5
source

Here's a tutorial on the Master / Detail template in Android - Android / tutorial tutorial / Learn more .

As far as I understand, your application is up and running, so I'm not sure whether to rewrite it if you do not have certain problems. :) In general, the flow of master data / details requires the following steps:

  • Implement ListFragment , showing basic information about your products.
  • Fragment implementation showing detailed information about a specific element
  • Create an xml layout file for large devices (for example, in the layout-sw600dp ). In this layout you should put both of your fragments.
  • Write a generic version of this layout file (i.e. a file with the same name but located in the layout folder) that contains only ListFragment.
  • Let your activity handle the onItemClick event of the ListFragment . Each time an element is clicked, you must check whether the activity shows both fragments or only ListFragment . If both of them are visible, you should notify the part fragment that a new element is selected so that it can show its data. Otherwise, you need to create a new fragment of parts (you reuse it), give it some information about the selected item (so that it can display the item data) and replace the ListFragment with a new one.

This is a basic overview, but it should be enough to give you some idea of ​​this stream. If you need any details, just let me know. :)

+2
source

Here are some links from developer.android.com fragment-ui and adaptui

These are some guidelines for fragments, but they are informed using the master / Detail application.

Also, be sure to check out the news reader application provided as a sample in the second link.

+2
source

The master / verbose flow and empty activity are not the same as you want to change, only changing the application theme or application theme. It would be better if you first develop a master / drillthrough template template using fragments of the user interface, and then integrate the empty action with the main template making the necessary changes. And for the wizard / detailed flow tutorial, just go to Google, you will find many examples there.

+2
source

If you have the latest version of the Android SDK installed, you can create a new Android application, and during this process you can choose to have the wizard create the Wizard / Detailed Stream application for you. He will create the main working application so that you can view the code and understand the necessary parts.

Then, depending on how simple your application is, you can move all your real code to a new application or vice versa.

Macro changes that will occur:

  • Instead, change all current activities to extend Fragment .
  • You will need to create a FragmentActivity to call your fragments. This will be basically the template code, only with the names of your snippets added to it.
  • Remember to double check your manifest!

In your converted snippets that previously extended the Activity:

  • getActivty() you need context, switch using getActivty() (or create a global variable so that it is called only once)
  • Change onCreate() to

     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.inflate(R.layout.fragment_signals, container, false); setHasOptionsMenu(true); // Add if you want to display a Menu // Your initiation code here return mView; } 
  • If you have a menu, change it to

     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.activity_main, menu); super.onCreateOptionsMenu(menu, inflater); } 

And this is for basic applications. When you first change "Actions to fragments", there will be many errors. But they are all easy to fix.

+2
source

Source: https://habr.com/ru/post/952467/


All Articles