How to call a view from the view ?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to call a view from the view ?

Postby JamesAndroid » Thu Dec 10, 2009 5:08 am

Hi guys.

I am a new developer for Android. I wanna know about View transitions.

For my application, it has 5 screens that can shift each other.

In order word, Screen1 -> Screen2 <--> Screen3
| |
Screen4 Screen4
| |
Screen5 Screen5

How to make this screen transition on Android ?

Please share the knowledge.

Thanks in advance.
JamesAndroid
Junior Developer
Junior Developer
 
Posts: 23
Joined: Mon Dec 07, 2009 7:23 am

Top

Postby andy@lg » Thu Dec 10, 2009 6:54 am

[font=Trebuchet]Hi,
As u told u r new to android, i would like to tell u the basics. In android Views / screens are called Activity. Please refer the API Demos application in the SDk Samples.
To start with, u must know abt :
Activity, Intents, Intent filter, Android Manifest file.. so on...

Please search over the net u wil get ample resources...!

All the best.
Landy[/font]
andy@lg
Freshman
Freshman
 
Posts: 8
Joined: Thu Feb 26, 2009 8:52 am

Easy to navigate through views.

Postby sanzeiev » Thu Dec 10, 2009 7:12 am

quick implementation read Activity, Intent and SetcontentView.

With the help of activity you can create another activity with help of intent.
Intent i = new Intent();
i.setClass(fromThecurrentClass.this,toNextClass.class);
startActivity(i);

in the toNextClass.java.
setContentView(R.layout.yourlayout);
you will get yourlayout view there. Which you need to create in layout folder with name yourlayout.xml

There are other method also but for the start it may help you.
sanzeiev
Freshman
Freshman
 
Posts: 8
Joined: Wed Jul 22, 2009 6:08 am

Postby JamesAndroid » Thu Dec 10, 2009 7:36 am

thanks. guys.

I've tried ViewFlipper to change the view.
It is not better way, when application has many Views(Screens).
Because it seems that initialized all Views on Activity->onCreate.

So, start up part of the application is very times up.
It is just my thought.

Is there any better way to work with many Views (their between transitions) ?

How is ViewSwitch for many views ?

Is it comfortable ?

PS :

Thanks sanzeiev. I'll try your idea. Then I post back. :)

Thanks in advance.
JamesAndroid
Junior Developer
Junior Developer
 
Posts: 23
Joined: Mon Dec 07, 2009 7:23 am

Dont forget to add new activity in the menifest.xml

Postby sanzeiev » Thu Dec 10, 2009 8:06 am

Dont forget to add new activity in the menifest.xml
sanzeiev
Freshman
Freshman
 
Posts: 8
Joined: Wed Jul 22, 2009 6:08 am

Postby JamesAndroid » Thu Dec 10, 2009 8:54 am

Wow. cool. Works fine.

Thank you. sanzeiev.

Now I would like to confirm about memory management.

Is there memory full crash, when call Activity->startActivity many times ?

How to declare local activity and static activity for android ?

Thanks in advance.
JamesAndroid
Junior Developer
Junior Developer
 
Posts: 23
Joined: Mon Dec 07, 2009 7:23 am

Top

Postby sanzeiev » Thu Dec 10, 2009 9:20 am

Well Good Catch!
I am also new in android, so I request other people to correct me if I go wrong.

Answer of 1. As much as I know about the memory management in android activity is like this
• As activities are launched across multiple processes, the memory footprint may grow beyond what is available
• Android will select low-priority processes for removal
• Activities further from the top of the navigation stack
• Services not in use by any visible activity
What if user pops stack back to killed activity?
Before showing a new activity, the activity losing focus is asked to load any non-persistent state into a “Bundle”, which is transferred to a manager process.


But even if you think, your application has more activity that may go beyond the memory. Then I will use Dialog for each activity. Means in the place of starting new activity every time I will start new dialog in place of that that will save my memory.
But dialog has limitations as dialog is part of view but it Is not an activity so I am not sure about navigating forward and backward to the dialogs. And launching dialog takes few millisecond more that the activity. So depend on scenario you can choose a mix of both activity and dialog.
sanzeiev
Freshman
Freshman
 
Posts: 8
Joined: Wed Jul 22, 2009 6:08 am

Postby JamesAndroid » Thu Dec 10, 2009 9:52 am

Thanks. I got your idea.
JamesAndroid
Junior Developer
Junior Developer
 
Posts: 23
Joined: Mon Dec 07, 2009 7:23 am

Postby Droid123 » Thu Dec 10, 2009 9:52 am

The post above me is not quite correct, it's also not very clear what you mean.

Concerning activities and such, you'll have to distinguish between
- Application
- Thread
- Process
- Activity
- Service
- Task

This is basically a summary of the Android fundamentals at:
http://developer.android.com/guide/topi ... ntals.html

but it took me a long while before I understood it properly.

1) One *.apk file is considered as One Application.
2) By Default: Every Application runs in its own Linux Process
3) Each process has it's own Dalvik Virtual Machine
4) One Application can contain several basic components (=Activities, services, broadcast receivers, content providers)
5) All of these components are executed on the main thread (= GUI thread) (Even services!)
6) It is possible to instantiate new threads within the Application

7) One Application can make use of components of other Applications (By intents, Activities and such)
8 ) When that happens the Android OS will start the other Application and therefor instantiate a new Dalvik VM

9) A Task is the way an user perceives and Application, it is a stack of activities which may belong to several Applications.
10) The back button causes the previous activity in this back stack to return to focus, the most current activitiy will be killed.

Activities are managed by the OS through the Activity Life cycle:
http://stuffthathappens.com/blog/wp-con ... rtical.png

In my experience the whole freeing up of memory and such doesn't work properly. It seems to me that this system needs to be tweaked to create a more usable environment. My 1.5 Android OS on the HTC Hero allows to much slowdown

[font=Arial] [/font]
Droid123
Experienced Developer
Experienced Developer
 
Posts: 77
Joined: Sat Nov 21, 2009 1:21 pm

Postby achie1266 » Thu Dec 10, 2009 5:22 pm

here is a video that explains about using multiple views and memory management and improving the performance.
http://www.youtube.com/watch?v=N6YdwzAvwOA
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby JamesAndroid » Fri Dec 11, 2009 3:52 am

Thanks guys,
I got your ideas
JamesAndroid
Junior Developer
Junior Developer
 
Posts: 23
Joined: Mon Dec 07, 2009 7:23 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests