
이런 형식의 화면을 구성하려는데 계속 에러가 나서 며칠째 제자리 걸음이네요;
저 망할 탭을 구현해야 다른걸 하는데 개발기간은 정해져있고 조급하기만 하네요.
일단 TabHost를 써서 하는걸 해보려는데 단순한 한개 버튼같은건 들어가는데(예제 따라하기;;)
아예 화면 집어넣는건 도저히 꿈도 못꾸고 있네요;
여러 고수님들이 조언해 주신건 일단
1. TabHost를 쓰고 수정을 해라
2. 버튼을 누르면 미리 지정된 xml을 inflate해서 addview 해라
등등이 있는데요;
어떻게 수정을 해야 하고 뭐가 잘못됬는지 자세한 조언을 부탁드립니다.
일단 계속 에러가 나서 화면 자체가 안뜨네요;;
소스 첨부합니다..
<main.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"
android:theme="@android:style/Theme.NoTitleBar">
<TabHost android:id="@+id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="0px" android:layout_height="fill_parent" />
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="151px" android:layout_height="fill_parent" android:background="@drawable/bg_left" android:orientation="vertical">
<Button android:id="@+id/Button01" android:layout_width="128px" android:layout_height="82px" android:layout_marginLeft="10px" android:layout_marginTop="16px" android:background="@drawable/menu01a_buddya"></Button>
<Button android:id="@+id/Button02" android:layout_marginLeft="10px" android:layout_height="82px" android:layout_width="128px" android:background="@drawable/menu02_people" android:layout_marginTop="10px"></Button>
<Button android:id="@+id/Button03" android:layout_height="82px" android:layout_width="128px" android:layout_marginLeft="10px" android:background="@drawable/menu03_now" android:layout_marginTop="10px"></Button>
<Button android:id="@+id/Button04" android:layout_height="82px" android:layout_width="128px" android:layout_marginLeft="10px" android:background="@drawable/menu04_phonep" android:layout_marginTop="10px"></Button>
<Button android:id="@+id/Button05" android:layout_height="82px" android:layout_width="128px" android:layout_marginLeft="10px" android:background="@drawable/menu05_setup" android:layout_marginTop="10px"></Button>
</LinearLayout>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:paddingTop="0px">
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
탭 위젯을 아예 줄이고 LinearLayout의 버튼이 눌리면 탭 위젯이 눌린것처럼 짜보았습니다.
<ImageSwitcherTestActivity.java>
package com.android.ImageSwitcherTest;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TabHost;
public class ImageSwitcherTestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
final TabHost tabs = (TabHost) findViewById(R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec = tabs.newTabSpec("tag1");
spec.setContent(R.id.tab1);
spec.setIndicator("Clock");
tabs.addTab(spec);
spec = tabs.newTabSpec("tag2");
spec.setContent(R.id.tab2);
spec.setIndicator("Button");
tabs.addTab(spec);
tabs.setCurrentTab(0);
final Button button2 = (Button) findViewById(R.id.Button02); // 사람들은
button2.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
button2.setBackgroundResource(R.drawable.menu02a_peoplea);
tabs.setCurrentTab(1);
}
});
}
}
-- 이건 테스트를 위해 단순 버튼과 시계만 띄우는건데 이건 잘 동작하더라구요--
새로 엑티비티를 만들어서 View 구역(파란색 네모칸)의 화면을 계속 바꾸고 싶습니다.
도움 부탁드립니다.



