0
탭이 필요한 Android 용 앱을 쓰고 있습니다. 내 목록의 콘텐츠가 내 탭 위로 이동했습니다. 나는 그것이 단순해야만한다는 것을 안다. 그러나 나는 그것을 발견 할 수 없다. 여기 Android : 콘텐츠 탭 위로 이동
내 main.xml에<TabWidget android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@android:id/tabs" />
<FrameLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@android:id/tabcontent">
</FrameLayout>
이며, 여기에 자바 코드를입니다
공용 클래스는 다시 TabActivity { @Override 공공 무효에서 onCreate를 (확장 Bundle savedInstanceState) { super.onCreate (s avedInstanceState); setContentView (R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, Download.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("download")
.setIndicator("", res.getDrawable(R.drawable.ok))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, Settings.class);
spec = tabHost.newTabSpec("settings")
.setIndicator("", res.getDrawable(R.drawable.ok))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}
어떤 도움을 크게 감상 할 수있다.
제이슨
tabactivity에서 setContentView를 호출하는 이유가 있습니까? 일반적으로 그렇게해서는 안됩니다. framelayout이 fill_parent로 설정되어 있기 때문에 거의 확실합니다. 당신은 tabactivity에 대한 전망이 필요하지 않습니다, 그것은 내부적으로 모두 가지고 있습니다. – Falmarri