2014-12-02 38 views
-2

我想製作一個Android應用程序,其中包含屏幕頂部的四個按鈕,當按下每個按鈕時,我需要這四個按鈕下方的不同屏幕。請告訴如何製作它。如何使一個屏幕爲Android中的多任務工作

+0

谷歌是你的朋友https://www.google.co.in/webhp?tab=ww&ei=caZ9VND9L4uPuASL4YG4Bw&ved=0CAYQ1S4#q=Android+Fragments+examples – 2014-12-02 12:10:54

+0

你創建喜歡TabView的? http://androidexample.com/Tab_Layout_%7C_TabBar_-_Android_Example/index.php?view=article_discription&aid=103&aaid=125 – 2014-12-02 12:12:53

+1

使用標籤和片段。沒有學習,你不能實現它。從這裏開始:http://developer.android.com/reference/android/support/v4/app/FragmentTabHost.html – 2014-12-02 12:13:53

回答

0

你應該使用片段...... 您可以構建一個包含1個片段的按鈕,以及一個視圖與一個片段取代它

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 
    <fragment 
     class:"com.example.ButtonFragment" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     tools:layout="@layout/button_fragment" /> 

    <FrameLayout 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="10" 
     android:id="@+id/LayoutForReplace"/> 

然後你可以設置如按鈕的動作偵聽器的活動這樣的:

getActivity().getFragmentManager().beginTransaction().replace(r.id.LayoutForRepalce, new SomeFragment()).commit(); 
+0

感謝所有.. – 2014-12-03 04:20:08

+0

@subhakarpatnala:如果有幫助,請不要忘記接受答案。 Tnx – K2evil 2014-12-03 11:45:44

+0

如何接受?@ K2evil – 2014-12-03 11:47:04

相關問題