간단한.. 책에 있는 예제인데도, 가상머신에 올리면 'The application has stoped unexpectedly~' 하면서 팅깁니다..
이클립스에선 에러가 안나는데도요..
초보자입장에서 이럴때 완전 멘붕이에요 ㅠㅠ 이유도 안알려주고 다짜고짜 팅기니...
대체 뭐가 문제일까요???
layout_main.xml
------------------------------------------------------------------
<LinearLayout android:id="@+id/opt_general"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="프로젝트명"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="변경"
/>
</LinearLayout>
<LinearLayout android:id="@+id/tab_layout1"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="최적화하기" />
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="경고 무시하기" />
</LinearLayout>
<TextView android:id="@+id/tab_layout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="링커의 옵션"/>
<TextView android:id="@+id/tab_layout3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="링커의 옵션"/>
</FrameLayout>
----------------------------------------------------------------
Main_Activity.java
------------------------------------------------------
package com.example.tabviewtest;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TabHost;
import android.app.*;
@SuppressWarnings("deprecation")
public class Main_Activity extends TabActivity {
TabHost mTab;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_main);
TabHost mTab = getTabHost();
LayoutInflater inflater = LayoutInflater.from(this);
inflater.inflate(R.layout.layout_main, mTab.getTabContentView(), true);
mTab.addTab(mTab.newTabSpec("tag")
.setIndicator("하나")
.setContent(R.id.tab_layout1));
mTab.addTab(mTab.newTabSpec("tag")
.setIndicator("둘")
.setContent(R.id.tab_layout2));
mTab.addTab(mTab.newTabSpec("tag")
.setIndicator("셋")
.setContent(R.id.tab_layout3));
}
/*
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
*/
}
----------------------------------------------------