Saturday, July 16, 2011

[android-developers] Android findViewById() problem

Hey guys the main layout xml file for my activity is
R.layout.date_list_layout as it is used as follows

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.date_list_layout);

However I wish to set the text in a TextView from this same activity
in another layout xml file R.layout.display_item

I know I would usually use the code below but this is not working as
the R.id.currency TextView is not in the main
R.layout.date_list_layout....

TextView currency = (TextView) findViewById(R.id.currency);
currency.setText(cur);

I know the next line of code is incorrect but is there a way to write
a similar line of code to access the R.id.currency in the
R.layout.display_item xml or can this not be done?

TextView currency = (TextView) findViewById(R.layout.display_item/
R.id.currency);
currency.setText(cur);

Some help would really be appreciated as this has me boggled the last
two days and I can't find any solution online

Thanks A

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment