Activity2.xml 布局上只有一个标签,标签 id 设置为 result+学号后 4 位。
时间: 2024-03-01 20:54:03 浏览: 32
假设你的学号为 12345678,那么可以按照以下方式设置 Activity2.xml 布局文件:
```
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/result5678"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 这里可以添加其他控件或布局 -->
</FrameLayout>
```
在这个布局文件中,我们使用了一个 `FrameLayout` 作为根布局,并将它的 `android:id` 属性设置为 `result5678`,也就是 `result` 后面加上学号后 4 位。你可以将这个布局文件保存在 `res/layout` 目录下,然后在 Activity2 中使用 `setContentView` 加载该布局文件。例如:
```
public class Activity2 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity2);
}
}
```
这样,当 Activity2 启动时,就会加载该布局文件,并将其中的控件显示在屏幕上。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)