How to change layout?

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

How to change layout?

Postby nr1 » Wed Aug 12, 2009 6:13 pm

Hi,

i created a menu (menu button) and want to activate a different "window" (layout) than the current.
How can i do this?
nr1
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Aug 11, 2009 6:27 pm

Top

Postby Emmanuel7 » Wed Aug 12, 2009 8:27 pm

This is the basis of Android programmation.

What you call windows are activities, and you launch another activity with the startActivityForResult / startActivity methods.

Hope it helps,
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Postby nr1 » Thu Aug 13, 2009 11:19 am

The problem is currently that i don't know how to switch from a "standard activity/view" to for example a ListView layout.

Can someone provide a demo?
nr1
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Aug 11, 2009 6:27 pm

Postby freewheelnat » Thu Aug 13, 2009 5:15 pm

For lists, your public class needs to extend ListActivity instead of extend Activity.

To "switch" from a normal view to a list view, you would create an intent to start a new Activity, except that this activity is in fact a ListActivity.

I've found these tutorials useful http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/view/index.html (scroll down the page to the list section)
freewheelnat
Developer
Developer
 
Posts: 40
Joined: Sat Aug 08, 2009 11:48 am
Location: London

Postby rafa_perfeito » Tue Aug 18, 2009 11:53 am

In a related matter,

How can i change a XML-defined layout in code? Lets assume that i have a layout in main.xml really cool an complex. And the i wanna change the text of one of the TextView in that layout. I can do :

mView = (View) mView.findViewById(R.layout.main);
and
mText = (TextView) mText.findViewById(R.id.text);

but, after changing mText, how can in 'merge' it with mView so i can define a new view? Even if i have to launch a new activity, i still need to create a new View from these changes to then apply on setContentView.

Any ideas? Thanks
rafa_perfeito
Freshman
Freshman
 
Posts: 3
Joined: Thu May 14, 2009 5:36 pm

Postby daliz » Tue Aug 18, 2009 12:12 pm

You don't have to merge and redraw the screen with the new (?) activity.

Simply invoke "setText()" on mText.
~ daliz ~ :: www.datapixel.eu
w w w . g e e k d r o i d . c o m
daliz
Junior Developer
Junior Developer
 
Posts: 21
Joined: Tue Jul 07, 2009 11:15 pm

Top

Postby rafa_perfeito » Tue Aug 18, 2009 1:20 pm

Damn i thought that worked only as a variable assignment...Android sure rocks...

Thanks dude
rafa_perfeito
Freshman
Freshman
 
Posts: 3
Joined: Thu May 14, 2009 5:36 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests