views:

34

answers:

2

Hi, may I know is it possible I use the resource id but I didnt set the Content View in the activity?

for example: abc.xml have one TextView id = "R.id.Text". Can I use the use TextView name = (TextView)findViewById(R.id.Text); method in the activity which was setContentView(R.layout.def);?

P/S: sorry about my bad english, hope you guys understand what I'm talking about.

Thanks

+1  A: 

Short answer: no. The code setContentView(R.layout.def); loads only the views from def.xml, not abc.xml. You have to use another method to create the TextView or include it in def.xml.

For another method to use for separate XML files, check out http://developerlife.com/tutorials/?p=303

onik
A: 

Check this link from Romain Guy

fedj