web*_*lex 3 xml android view widget android-layout
我们拥有文件的Android Studio 1.4新模式conten_main.xml。
我需要FrameLayout从该文件中获取一个View,但这findViewById()是不可能的。因为ActivityMain.java有activity_main.xml布局,其中包括
app_bar_activity_main.xml布局,其中包括content_main.xml布局。
我如何从中获得FrameLayout视图content_main.xml?
要访问您包含的布局,请添加一个id,如下所示:
<include
android:id="+id/id_content_main"
layout="@layout/content_main" />
Run Code Online (Sandbox Code Playgroud)
然后像这样访问它
View contentView = findViewById(R.id.id_content_main);
FrameLayout layout = (FrameLayout)contentView.findViewById(R.id.frame_layout_id);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2335 次 |
| 最近记录: |