조각 활동에 탭 호스트를 넣으려고합니다. 탭을 보유하고 해당보기를 tabhost 의 setIndicator에 넣으려는 사용자 정의 레이아웃을 만들었지 만, 불행히도 탭은 그렇지 않습니다.조각 활동에 탭이 나타나지 않습니다.
: 이것은 내 사용자 지정 탭 레이아웃이다<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/black">
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="52dp" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
</android.support.v4.app.FragmentTabHost>
</LinearLayout>
... 아무도 도움이 될 수 있습니다 ......
public class MainActivity extends FragmentActivity {
private FragmentTabHost mTabHost;
LayoutInflater inflater;
View tabdesign, tabSplitter;
AddFragment addfragment;
private ImageView label;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
//check configuration
// Configuration config = getResources().getConfiguration();
//setting up tabs
tabdesign = inflater.inflate(R.layout.inside_tab_design, null);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.content);
inflater = (LayoutInflater) getBaseContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
label=(ImageView)tabdesign.findViewById(R.id.tablabel);
label.setImageResource(R.drawable.settings);
mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator(tabdesign),
SmallFragment.class, null);
tabSplitter = (View) tabdesign.findViewById(R.id.tabSplitter);
tabdesign = inflater.inflate(R.layout.inside_tab_design, null);
label = (ImageView) tabdesign.findViewById(R.id.tablabel);
label.setImageResource(R.drawable.settings);
mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator(tabdesign),
TabeFragment.class, null);
}
}
를이 내 주요 XML됩니다 보여주는
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tab"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="#898989"
android:orientation="vertical" >
<View
android:id="@+id/tabSplitter"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#ffffff" />
<ImageView
android:id="@+id/tablabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
, 당신은 단지 그 하나의 탭 요소를 당신의 XML에 TabHost,하지만하지 않았습니다. 적어도 하나를 추가해야합니다 –
Fraggles