use*_*667 5 android include relativelayout
我必须开发一个Android应用程序.
我创建了一个使用include标签使用另一个布局文件的布局文件.
<include
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
layout="@layout/footer_tabs" />
<include
android:id="@+id/footer1"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
layout="@layout/footertabs" />
Run Code Online (Sandbox Code Playgroud)
我想在响应为空时显示包含的布局,否则我想隐藏布局并显示另一个.这是我到目前为止:
footertabs = (RelativeLayout) findViewById(R.id.footertab);
footer_tabs = (RelativeLayout) findViewById(R.id.footer_tab);
if (Constants.response==null) {
footertabs.setVisibility(View.VISIBLE);
footer_tabs.setVisibility(View.GONE);
}
else
{
footertabs.setVisibility(View.GONE);
footer_tabs.setVisibility(View.VISIBLE);
}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
07-15 17:19:09.893: E/AndroidRuntime(15143): Caused by: java.lang.NullPointerException
07-15 17:19:09.893: E/AndroidRuntime(15143): at com.example.androidbestinuk.HomePage.onCreate(HomePage.java:56)
Run Code Online (Sandbox Code Playgroud)
请帮我调试这个错误.
你应该改变
footertabs = (RelativeLayout) findViewById(R.id.footertab);
footer_tabs = (RelativeLayout) findViewById(R.id.footer_tab);
Run Code Online (Sandbox Code Playgroud)
同
footertabs = (RelativeLayout) findViewById(R.id.footer);
footer_tabs = (RelativeLayout) findViewById(R.id.footer1);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11422 次 |
| 最近记录: |