안드로이드 개발 질문/답변
(글 수 45,052)
각 액티비티 하단에 Tabhost를 사용해서 배치할려고 합니다.
src=java 페이지
이렇게 설정하고 난후 애뮬레이터를 실행하면은 하단탭이 형성이 안보이는데요;;
어떤부분이 잘못 되었는지 모르겠습니다. 에러는 안뜨는데. 탭뷰가 안보이네요;;
src=java 페이지
package com.xxx;
import android.app.*; import android.content.*; import android.os.*; import android.widget.*; import android.widget.TabHost.*;
public class MainActivity extends TabActivity{
public static TabHost tabhost;
TabHost.TabSpec spec;
Intent intent;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainactivity);
tabhost = getTabHost();
intent = new Intent().setClass(this, xxx.class);
spec = tabhost.newTabSpec("xxx")
.setIndicator(new MyView(this, R.drawable.xxx))
.setContent(intent);
tabhost.addTab(spec);
intent = new Intent().setClass(this, xxx2.class);
spec = tabhost.newTabSpec("xxx2")
.setIndicator(new MyView(this, R.drawable.xxx2))
.setContent(intent);
tabhost.addTab(spec);
intent = new Intent().setClass(this, xxx3.class);
spec = tabhost.newTabSpec("xxx3")
.setIndicator(new MyView(this, R.drawable.xxx3))
.setContent(intent);
tabhost.addTab(spec);
intent = new Intent().setClass(this, xxx4.class);
spec = tabhost.newTabSpec("xxx4")
.setIndicator(new MyView(this, R.drawable.xxx4))
.setContent(intent);
tabhost.addTab(spec);
tabhost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
}
});
tabhost.setCurrentTab(0);
}
private class MyView extends LinearLayout {
public MyView(Context c, int drawable) {
super(c);
ImageView iv = new ImageView(c);
iv.setBackgroundResource(drawable);
addView(iv);
}
}
}XML페이지<?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="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="0dp">
<FrameLayout android:id="@android:id/tabcontent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1"/>
<TabWidget android:id="@android:id/tabs" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="bottom"/>
</LinearLayout> </TabHost> </LinearLayout>
이렇게 설정하고 난후 애뮬레이터를 실행하면은 하단탭이 형성이 안보이는데요;;
어떤부분이 잘못 되었는지 모르겠습니다. 에러는 안뜨는데. 탭뷰가 안보이네요;;



