开发者

Resource ID question

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开发者_如何学Python(R.layout.def);?

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

Thanks


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜