처음에 애뮬레이터 실행하자마자
탭으로 된 화면이 나오면 바라는데요
package com.androidbook.layout;
import java.util.Date;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;
public class TabLayout extends TabActivity implements android.widget.TabHost.TabContentFactory {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost tabHost = getTabHost();
LayoutInflater.from(this).inflate(R.layout.example_layout, tabHost.getTabContentView(), true);
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Grid").setContent(new Intent(this, GridLayout.class)));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("List").setContent(new Intent(this, List.class)));
tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("Basic").setContent(R.id.two_texts));
tabHost.addTab(tabHost.newTabSpec("tab4").setIndicator("Factory").setContent(this));
}
public View createTabContent(String tag) {
if (tag.compareTo("tab4") == 0) {
TextView tv = new TextView(this);
Date now = new Date();
tv.setText("I'm from a factory. Created: " + now.toString());
tv.setTextSize((float) 24);
return (tv);
} else {
return null;
}
}
}
이렇게 응용해보려고 하는데..
원래 처음에 실행될 때는 Activity 여야 하잖아요~
근데 이건 TabActivity 확장형이라 그런지
이 화면을 제일 처음에 띄우려고 하면 에러가 나더라구요
어떻게 해야하나요????
public class TabLayout extends Activity {
}
이 안에서 위의 내용을 다시 정의해줘야 하는건가요?
어떻게 하는건지 잘 모르겠어요;
TabLayout.class가 애뮬레이터 실행되자마자 보여야 하는 화면이구요....
TabHost를 사용하기 위해서 Activity을 TabActivity로 변경해줬어요
로그캣은 아무것도 찍히지 않구요..
디버그는
DalvikVM[localhost:8666]
Thread [<1> main] (Suspended (exception RuntimeException))
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679
ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125
ActivityThread$H.handleMessage(Message) line: 2033
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]
Thread [<6> Binder Thread #2] (Running)
Thread [<5> Binder Thread #1] (Running)
이렇게 나와요~




일단 에러 로그를 첨부해주세요