虽然我们可以使用java code来编写UI,但是更通用的方式是使用XML-based Layout文件,它用于描述widget和container之间的关系。这使得我们可以方便阅读和是UI设计独立,也使得一些IDE工具可以提供直观的GUI。
1、修订main.xml
java代码:
2、在源代码中,通过我们在xml中定义的名字来获取该实例
java代码:
3、运行,如图所示
1、修订main.xml
java代码:
2、在源代码中,通过我们在xml中定义的名字来获取该实例
java代码:
3、运行,如图所示