GUI: Navigate through XML Files

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

GUI: Navigate through XML Files

Postby Hartl » Sat Jun 14, 2008 5:18 pm

Hello, I think my question is not really difficult, but I am a very beginner, sorry for that :-)
I have created 3 xml (layout) files for a little game.
There is the title screen/screen01 (with a "new game" button), the give-name-in screen/screen02 (with "back" and "ok" buttons (and a textentry-field)) and the overview screen/screen03 (also with "back" and "ok" buttons).

So, I want to connect these 3 screens, that i can navigate between these 3 screens.
For example:
- click "new game" button (screen01)
- click "back" button (screen02 - want to go back to the title screen)
- click again "new game" button (screen01)
- click "ok" button (screen02 - i typed my name in)
- click "back" button (screen03 - i noticed, i didn't type the correct name in ;D)
- and so on...

Ok, so i tried it with:

public void onCreate(Bundle icicle) {

super.onCreate(icicle);
//my start title screen
setContentView(R.layout.screen01);

Button screen01_newgame_button = (Button) findViewById (R.id.screen01_newgame_button);
screen01_newgame_button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setContentView(R.layout.screen02);
}
});
}

--> This works, but how can I i.e. navigate back to the title screen (screen01) or navigate to the overview screen (screen03) ???
--> Do I have to make a own class for each xml-file???
--> Or is it possible to do this navigation thing in one class???

I don't exactly know, but I think I need a own class for each xml file. The problem is, that i don't know how to connect these classes...
Excuse me for my terrible english :D I know, it's very bad...
Hartl
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jun 14, 2008 4:48 pm

Top

Use Activity

Postby AsTeR » Thu Jun 19, 2008 9:15 am

As described in the [url=http://code.google.com/android/intro/anatomy.html]Anatomy of an Androïd application[/url] you should use two different Activity instead of trying to switch views.

You shall look the second exercice in the tutorial that is using two different activities, one for listing notes, the other for editing. The tutorial is : [url=http://code.google.com/android/intro/tutorial.html#exercises]here[/url];

Nice day and good luck !
AsTeR
Junior Developer
Junior Developer
 
Posts: 19
Joined: Tue Jun 17, 2008 8:36 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 14 guests