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 http://www.helloandroid.com/content/creating-view-activity-causing-strange-id-issue#
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, http://www.helloandroid.com/content/creating-view-activity-causing-strange-id-issue#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
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 http://www.helloandroid.com/content/creating-view-activity-causing-strange-id-issue#
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, http://www.helloandroid.com/content/creating-view-activity-causing-strange-id-issue#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