안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요~
하단 탭의 구현은
입니다.
한 화면에 Tab이 이중으로 들어가는 앱을 만들려고합니다.
상단에 탭이 하나, 하단에 탭이 하나로 만들려는 것이죠.
하단 탭의 선택에 따라, tabcontent 부분에 그냥 새로운 tab host를 넣어줬더니,
상단 탭이 위로 올라가지 않고, 하단탭에 붙어버리는 현상이 발생합니다
상단 탭의 구현은
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
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">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_above="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</FrameLayout>
</RelativeLayout>
</TabHost>
</LinearLayout>
하단 탭의 구현은
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
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="fill_parent"
>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
</TabHost>
어떻게 하면 상단탭을 위로 보낼 수 있을까요 :)?
탭을 추가하는 소스는
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
public class freindTabMain extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.doubletap);
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, tabview1.class);
spec = tabHost.newTabSpec("tab1").setIndicator("uppertab1").setContent(intent);
tabHost.addTab(spec);
}
}
와 같이 구현되었습니다
TabActivity는 2개로 쓰지 마시고 하나는 ActivityGroup을 쓰시는게 나을거 같습니다.
그리고 ActivityGroup으로 쓰는 TabHost는 id를 바꿔서 쓰세요...
아이디가 같으니 걍 한군데로 몰리는듯 합니다.