在Android中,我可以有不同的活动中使用相同的XML文件? [英] In Android, can I have different Activities use the same XML file?

查看:121
本文介绍了在Android中,我可以有不同的活动中使用相同的XML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个Android应用程序,将有多个页面具有相同的布局,但改变将是(使用的setText)显示在顶部的字符串的唯一的事。我可以使用这些网页一个XML文件,还是安卓不允许呢?

I'm creating an android app that will have multiple pages with the same layout, but the only thing that changes will be a string that is displayed on the top (using setText). Can I use a single xml file for these pages, or does Android not allow that?

推荐答案

是的,你可以。只要打电话的setContentView具有相同的XML,它会使用相同的布局。更改任何你需要以编程方式在运行时。

Yes, you can. Just call "setContentView" with the same xml and it will use the same layout. Change whatever you need to programmatically during runtime.

这篇关于在Android中,我可以有不同的活动中使用相同的XML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆