newbie activity/layout/views question

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

newbie activity/layout/views question

Postby mbeattie » Sat Apr 17, 2010 3:31 pm

I am really new to android dev but am learning. I have a few questions I hope someone could answer. First, an Activity is like a "process" or like a "window"? It seems that it's really like neither. For example, I could have an app that has multiple activities, right? If I wanted to have say 2 different layouts, should I call setContentView() again with the other layout to change it or start a new activity that does all of the layout/buttons/whatever? Would it be bad to have an activity that is tied to buttons or other controls that might not be on the "main" layout for that activity? If I switch activities, should I finish() the current one somehow? Or will finish() close the whole app?
mbeattie
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Apr 17, 2010 3:24 pm

Top

Postby androidjutsu » Mon Apr 19, 2010 8:39 am

Each time a new activity starts, it will automatically call it's onCreate() method.

So, simply change the layout called in setContentView() in the onCreate() method.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4. public void onCreate(Bundle b) {
  5.  
  6. super.onCreate(b);
  7.  
  8. setContentView(R.layout.ANY_XML_LAYOUT);
  9.  
  10.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
androidjutsu
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sun Apr 18, 2010 6:51 pm
Location: London

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 7 guests