Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old September 9th, 2011, 08:15 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Jul 2010
Posts: 7
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating a (VIEW) activity causing strange TextView issue

Ok,


Please bear with me, it's my first day on Android!



Sorry for the long-winded post too !
Not sure what to make of this one


I have a Linear layout in Vertical orientation which has two text fields, then a list.


The list is intended to use a Custom ListView that I have adapted from one I found

So my main Activity code goes like this




public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Needs to come from stable storage obviously
TextView UsernameView = (TextView)findViewById(R.id.welcome_user);
UsernameView.setText("Welcome, Nick");
UsernameView = (TextView)findViewById(R.id.fc);
UsernameView.setText("Welcome, Nick");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName(this, FCItemListView.class.getName());
//intent.setClassName(this.activity, FCItemListView.class);
startActivity(intent);
}


Where FCItemListView is derived from Activity.
R.id.fc and R.id.welcome_user are defined in my Strings


The OnCreate for the FCItemListView goes like this
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


ListView listView = (ListView)findViewById(R.id.fc_item_list);


So you can see it sets its content view to main, and then references the original list in main.xml


And fc_text is defined as a String resource.


So the issue here is That if I exclude these lines
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName(this, FCItemListView.class.getName());

startActivity(intent);
Then my two text boxes are as expected, "Welcome Nick" and obviously no List is displayed


However, if I add in those lines (to open the List) into my main activity

Then the list is displayed, BUT the text in the text views is set to the fc string resource, and does not update with the setText call





I am honestly at a bit of a loss on how that could happen, especially as the Intent/Start code comes AFTER the code to set the TextBoxes so I dont see how if affects it.


One additional thing is that if I put


This
UsernameView = (TextView)findViewById(R.id.fc);
UsernameView.setText("Welcome, Nick");


*inside* the onCreate for the new activity, it updates just fine.


I thought at first it was the additional setContentView(R.layout.main); inside the sub-view that was maybe re-doing the main layout, but even if I open the list in the main activity THEN do the setText, it still doesn't work correctly.


Hopefully someone has some suggestions ?


Thanks,


Nick

Advertisements
limeyx is offline  
Reply With Quote
sponsored links
Reply
Tags
list, textview


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:22 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.