2014-12-02 35 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

相关问题