我必须开发一个

Android应用程序.

我创建了一个布局文件,使用include标签使用另一个布局文件.

android:id="@+id/footer"

android:layout_width="match_parent"

android:layout_height="60dp"

android:layout_alignParentBottom="true"

layout="@layout/footer_tabs" />

android:id="@+id/footer1"

android:layout_width="match_parent"

android:layout_height="60dp"

android:layout_alignParentBottom="true"

layout="@layout/footertabs" />

我想在响应为空时显示包含的布局,否则我想隐藏布局并显示另一个.这是我到目前为止:

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);

}

但是我收到以下错误:

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)

请帮我调试这个错误.

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐