Я никогда раньше не проектировал пользовательские интерфейсы (скорее, связующее звено), поэтому извиняюсь, если вопрос глупый. Я проектирую пользовательский интерфейс, чтобы он выглядел примерно так:
ImageView ImageView
TabHost
Вкладка 0 ------ Вкладка 1 ------ Вкладка 2
----- ВНУТРИ КАЖДОГО TAB -----
TextView
ListView
- состоит из ImageView TextView
Проблема в том, что я думаю, что следую очень неэффективному способу делать все это. Метод onCreate выглядит следующим образом:
КОД:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost mTabHost = getTabHost();
Drawable Tab1Icon = getResources().getDrawable(R.drawable.tab1_icon);
Drawable Tab2Icon = getResources().getDrawable(R.drawable.tab2_icon);
Drawable Tab3Icon = getResources().getDrawable(R.drawable.tab3_icon);
mTabHost.addTab(mTabHost.newTabSpec("Tab1").setIndicator("Tab 1", Tab1Icon).setContent(new Intent(this, Tab1.class)));
mTabHost.addTab(mTabHost.newTabSpec("Tab2").setIndicator("Tab 2", Tab1Icon).setContent(new Intent(this, Tab2.class)));
mTabHost.addTab(mTabHost.newTabSpec("Tab3").setIndicator("Tab 3", Tab1Icon).setContent(new Intent(this, Tab3.class)));
mTabHost.setCurrentTab(0);
}
Эта программа вылетает на CupCake (v1.5) с жалобой на StackOverflowException, но хорошо работает на Donut (v1.6). Это мой 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:background="@color/application_background"
>
<TableLayout
android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="0"
android:background="@color/application_background">
<TableRow>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView id="@+id/picview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/leftlogo"
android:paddingRight="105sp"
/>
<Button
android:id="@+id/picview2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rightlogo"
/>
</LinearLayout>
</TableRow>
<TableRow>
<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">
</FrameLayout>
</LinearLayout>
</TabHost>
</TableRow>
</TableLayout>
</LinearLayout>
Любые предложения, касающиеся дизайна, пожалуйста?
Спасибо