hollister
- Forum-Beiträge: 5
25.11.2010, 00:18:23 via Website
25.11.2010 00:18:23 via Website
Hi,
ich möchte gerne ein TabHost mit einem TabWidget einsetzen, dass im ersten Tab mehrere Activitys nacheinander darstellen kann.
Soweit ich weiß eignet sich hierzu die ActivityGroup sehr gut. Allerdings bin ich bisher zu keinem brauchbaren Ergebnis gekommen.
Im Grunde habe ich bereits mehrere Activitys mit je einer ListVIew erstellt, die im Kern wie folgt aussehen und funktionieren:
main.xml (standard)
first.xml
Jetzt würde ich gerne diese mit um die TabHost erweitern.
Hier ein Ansatz, den ich gern als tablayout.xml nutzen würde:
Würde mich über einen brauchbaren Ansatz einer Javaklasse und Layoutfile freuen. Danke.
ich möchte gerne ein TabHost mit einem TabWidget einsetzen, dass im ersten Tab mehrere Activitys nacheinander darstellen kann.
Soweit ich weiß eignet sich hierzu die ActivityGroup sehr gut. Allerdings bin ich bisher zu keinem brauchbaren Ergebnis gekommen.
Im Grunde habe ich bereits mehrere Activitys mit je einer ListVIew erstellt, die im Kern wie folgt aussehen und funktionieren:
1public class firstactivity extends ListActivity{
2 public Order order = new Order();
3 private ProgressDialog m_ProgressDialog = null;
4 private ArrayList<Order> orders_book = null;
5 private OrderAdapter adapter_overview;
6 private Runnable viewOrders;
7
8 @Override
9 public void onCreate(Bundle savedInstanceState) {
10 super.onCreate(savedInstanceState);
11 setContentView(R.layout.main);
12
13 /** Create a new layout to display the view */
14 LinearLayout layout = new LinearLayout(this);
15 layout.setOrientation(1);
16 orders_book = new ArrayList<Order>();
17 this.adapter_overview = new OrderAdapter(this, R.layout.first, orders_book);
18
19 setListAdapter(this.adapter_overview);
20 viewOrders = new Runnable(){
21 @Override
22 public void run() {getBookTitle();}
23 };
24
25 Thread thread = new Thread(null, viewOrders, "MagentoBackground");
26 thread.start();
27 m_ProgressDialog = ProgressDialog.show(firstactivity.this,
28 "Please wait", "123", true);
2 public Order order = new Order();
3 private ProgressDialog m_ProgressDialog = null;
4 private ArrayList<Order> orders_book = null;
5 private OrderAdapter adapter_overview;
6 private Runnable viewOrders;
7
8 @Override
9 public void onCreate(Bundle savedInstanceState) {
10 super.onCreate(savedInstanceState);
11 setContentView(R.layout.main);
12
13 /** Create a new layout to display the view */
14 LinearLayout layout = new LinearLayout(this);
15 layout.setOrientation(1);
16 orders_book = new ArrayList<Order>();
17 this.adapter_overview = new OrderAdapter(this, R.layout.first, orders_book);
18
19 setListAdapter(this.adapter_overview);
20 viewOrders = new Runnable(){
21 @Override
22 public void run() {getBookTitle();}
23 };
24
25 Thread thread = new Thread(null, viewOrders, "MagentoBackground");
26 thread.start();
27 m_ProgressDialog = ProgressDialog.show(firstactivity.this,
28 "Please wait", "123", true);
main.xml (standard)
1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="fill_parent"
5 android:layout_height="fill_parent"
6 android:id="@layout/main">
7<ListView
8 android:id="@+id/android:list"
9 android:layout_width="fill_parent"
10 android:layout_height="fill_parent"
11 />
12<TextView
13 android:id="@+id/android:empty"
14 android:layout_width="fill_parent"
15 android:layout_height="fill_parent"
16 android:text="@string/main_loader_text"/>
17</LinearLayout>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="fill_parent"
5 android:layout_height="fill_parent"
6 android:id="@layout/main">
7<ListView
8 android:id="@+id/android:list"
9 android:layout_width="fill_parent"
10 android:layout_height="fill_parent"
11 />
12<TextView
13 android:id="@+id/android:empty"
14 android:layout_width="fill_parent"
15 android:layout_height="fill_parent"
16 android:text="@string/main_loader_text"/>
17</LinearLayout>
first.xml
1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="?android:attr/listPreferredItemHeight"
5 android:id="@layout/first">
6
7 <ImageView
8 android:id="@+id/icon"
9 android:layout_width="wrap_content"
10 android:layout_height="fill_parent"
11 android:layout_marginRight="10dip"
12 android:src="@drawable/icon" />
13 <LinearLayout
14 android:orientation="vertical"
15 android:layout_width="0dip"
16 android:layout_weight="1"
17 android:layout_height="fill_parent">
18 <TextView
19 android:id="@+id/toptext"
20 android:layout_width="fill_parent"
21 android:layout_height="0dip"
22 android:layout_weight="1"
23 android:textColor="@color/white"
24 />
25 </LinearLayout>
26</LinearLayout>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="?android:attr/listPreferredItemHeight"
5 android:id="@layout/first">
6
7 <ImageView
8 android:id="@+id/icon"
9 android:layout_width="wrap_content"
10 android:layout_height="fill_parent"
11 android:layout_marginRight="10dip"
12 android:src="@drawable/icon" />
13 <LinearLayout
14 android:orientation="vertical"
15 android:layout_width="0dip"
16 android:layout_weight="1"
17 android:layout_height="fill_parent">
18 <TextView
19 android:id="@+id/toptext"
20 android:layout_width="fill_parent"
21 android:layout_height="0dip"
22 android:layout_weight="1"
23 android:textColor="@color/white"
24 />
25 </LinearLayout>
26</LinearLayout>
Jetzt würde ich gerne diese mit um die TabHost erweitern.
Hier ein Ansatz, den ich gern als tablayout.xml nutzen würde:
1<TabHost android:layout_width="fill_parent"
2 android:layout_height="fill_parent"
3 android:id="@android:id/tabhost"
4 xmlns:android="http://schemas.android.com/apk/res/android"
5 >
6 <RelativeLayout
7 android:layout_width="fill_parent"
8 android:layout_height="fill_parent"
9 >
10 <TabWidget
11 android:layout_width="fill_parent"
12 android:layout_height="wrap_content"
13 android:id="@android:id/tabs"
14 android:layout_alignParentBottom="true"
15 />
16 <FrameLayout
17 android:layout_width="fill_parent"
18 android:layout_height="fill_parent"
19 android:id="@android:id/tabcontent"
20 >
21
22 </FrameLayout>
23 </RelativeLayout>
24 </TabHost>
2 android:layout_height="fill_parent"
3 android:id="@android:id/tabhost"
4 xmlns:android="http://schemas.android.com/apk/res/android"
5 >
6 <RelativeLayout
7 android:layout_width="fill_parent"
8 android:layout_height="fill_parent"
9 >
10 <TabWidget
11 android:layout_width="fill_parent"
12 android:layout_height="wrap_content"
13 android:id="@android:id/tabs"
14 android:layout_alignParentBottom="true"
15 />
16 <FrameLayout
17 android:layout_width="fill_parent"
18 android:layout_height="fill_parent"
19 android:id="@android:id/tabcontent"
20 >
21
22 </FrameLayout>
23 </RelativeLayout>
24 </TabHost>
Würde mich über einen brauchbaren Ansatz einer Javaklasse und Layoutfile freuen. Danke.
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.