Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single XML, Multiple Activity & there Performance

I have some simple questions for Android Users.

  1. If I use Single XML for Multiple Activity, What issues might come ??

  2. How it ll help in Application PERFORMANCE, if we use this kind of approach ??

for example : If have same XML layouts A,B,C for A,B,C Activity, Instead of using multiple layout I want to use only single Layout i.e. A XML Layout for A,B,C Activity.

Note: I have tried this, works fine. But I want to know that any issues or problem using this kind of approach. Gone through some sites but din't get cleared picture

Suggestions or help will be appreciated.

Many Thanks ..!!

like image 476
Rahul Baradia Avatar asked Dec 21 '12 06:12

Rahul Baradia


People also ask

How to use a single class in multiple activities in Android?

This article explains how to use a single class in multiple Activities in Android. Suppose in your Android application there is a class that you need to use in every Android Activity. For example, you use a progress bar in your application and the progress bar will be the same for all the classes to show functionality.

What is an example of multiple activities?

Multiple Activities Even the simplest applications have more than one functionality. Hence, there is often a need to deal with multiple activities. For example, a game can have two activities: a high scores screen and a game screen.

What are the best libraries to implement a single activity application?

Below is the list of useful libraries in case you decide to implement a Single- Activity Application. Cicerone is a lightweight library that makes the navigation in Android app easier to implement Dagger 2 is a fast dependency injector for Android and Java.

How to create an Android app from an XML file?

Put the activity name and the layout name. Android Studio basically takes a Java class name, which you provide for the activity name and click Finish. Go to activity_first.xml, followed by clicking the text bottom. This XML file contains the designing code for an Android app.


1 Answers

There's no problem at all. The XML will get inflated as separate instances for each Activity.

Note that because they are separate instances, any data on those forms won't be shared between them, though; you would need to pass data between activities as extras on an intent or through a persistence mechanism (databases, shared prefs, etc)

like image 77
Scott Stanchfield Avatar answered Oct 06 '22 20:10

Scott Stanchfield