Changes in main.xml are not reflecting on the emulator

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Changes in main.xml are not reflecting on the emulator

Postby sm » Wed Sep 10, 2008 11:14 pm

Hey,

I am trying to change text on the main.xml file: android:text=" Any text here", but it is not reflecting on the
emulator display. Instead, the text in the tv.setTextView(" Text" ); in the .java file gets displayed.

Can anyone suggest a resolve for this?

Thanks!
sm
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Sep 05, 2008 2:54 am

Top

Postby cadlg » Wed Sep 10, 2008 11:30 pm

Hello sm. I hope I didn't misunderstand your question.

In general, almost any java code (such as tv.setTextView(" Text" )) will be executed after the view is inflated based on the xml parameters, so I would think that the text set at xml is in fact being displayed, but the text is changed programmatically immediately after that.

Try commenting this line
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. tv.setTextView(" Text" )
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Regards,
cadlg
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Feb 20, 2008 12:33 am
Location: Guatemala

Postby sm » Wed Sep 10, 2008 11:42 pm

Exactly!! Thats just what's happening. I just did that and its displaying now.

Your comments re-inforced my hunch

Thanks!
sm
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Sep 05, 2008 2:54 am

Postby sm » Thu Sep 11, 2008 12:14 am

Hey,

How do u get other xml files to start working? Is every xml file tied to the .java file?

thnx
sm
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Sep 05, 2008 2:54 am

Postby Xav » Fri Sep 12, 2008 2:03 am

sm wrote:How do u get other xml files to start working? Is every xml file tied to the .java file?


XML layout files are not associated to any java file.

In the template application created by activityCreator or the Eclipse plugin, you should see a call to setContentView in the activity onCreate method.

What this does is set a layout (referenced by its R.layout id) as the content of the activity UI.

Any activity can use any layout as their content. Activities can share the same layout, or activities could dynamically change their content.
User avatar
Xav
Junior Developer
Junior Developer
 
Posts: 11
Joined: Fri Dec 14, 2007 3:09 am
Location: Mountain View, CA

Postby sm » Fri Sep 12, 2008 2:19 am

Thanks!
sm
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Sep 05, 2008 2:54 am

Top

Return to General

Who is online

Users browsing this forum: No registered users and 7 guests