本文介绍了里面的LinearLayout的Android TabHost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿...我试图创建的布局结构这样一个活动:
Hey... i'm trying to create an activity with the layout structure like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TabHost android:id="@+id/tabHost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TabWidget android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@android:id/tabs"
/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</FrameLayout>
</LinearLayout>
</TabHost>
<some code here>
</LinearLayout>
什么是错在这里?我得到的NullPointerException在我的活动
What is wrong here? I'm getting nullPointerException in my activity
public class TabsActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs);
// Resources res = getResources();
// TabHost tabHost = (TabHost)findViewById(R.id.tabHost);
}
}
问题是与嵌套。存在与TabHost为主体的XML节点中的任何问题。THX!
The problem is with nesting. There is no problem with the TabHost as the main XML node.Thx!
错误:
Error:
推荐答案
我也有类似的问题和解决方案是让 TabHost
并调用设置()
。很难说,如果这是你的问题就在这里。
I had a similar problem and the solution was to get the TabHost
and call setup()
. Hard to say if that's your problem here.
这篇关于里面的LinearLayout的Android TabHost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!