AndroidManifest.xml
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
...
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AudioActivity"
android:label="@string/title_activity_audio" >
</activity>
<activity
android:name=".PlayingPeriodActivity"
android:label="@string/title_activity_playing_period_view" >
</activity>
<activity
android:name=".ClockActivity"
android:label="@string/title_activity_clock" >
</activity>
<activity
android:name=".LightActivity"
android:label="@string/title_activity_light" >
</activity>
<activity
android:name=".PanelActivity"
android:label="@string/title_activity_panel" >
</activity>
<activity
android:name=".SearhingDevideActivity"
android:label="@string/title_activity_search_devide" >
</activity>
<activity
android:name=".MemberPanelActivity"
android:label="@string/title_activity_member_panel" >
</activity>
<activity
android:name=".ConnectingDevideActivity"
android:label="@string/title_activity_connect_device" >
</activity>
</application>
activity_main.xml
<TabHost
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tabHost"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"></TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
</TabHost>
activity_clock.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="新增闹钟"
android:id="@+id/btnNewClock"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:onClick="newClock" />
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lvClockView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_above="@+id/btnNewClock"
android:choiceMode="singleChoice" />
</RelativeLayout>
</LinearLayout>
...
activity_audio.xml
activity_light.xml
activity_panel.xml
will be the same.
MainActivity.java
host = (TabHost)findViewById(R.id.tabHost);
// host.setup();
LocalActivityManager mLocalActivityManager = new LocalActivityManager(this, false);
mLocalActivityManager.dispatchCreate(savedInstanceState);
host.setup(mLocalActivityManager);
TabHost.TabSpec spec1 = host.newTabSpec("tab1");
spec1.setIndicator("闹钟");
spec1.setContent(new Intent(this, ClockActivity.class));
host.addTab(spec1);
TabHost.TabSpec spec2 = host.newTabSpec("tab2");
spec2.setIndicator("播放");
spec2.setContent(new Intent(this, AudioActivity.class));
host.addTab(spec2);
TabHost.TabSpec spec3 = host.newTabSpec("tab3");
spec3.setIndicator("灯光");
spec3.setContent(new Intent(this, LightActivity.class));
host.addTab(spec3);
TabHost.TabSpec spec4 = host.newTabSpec("tab4");
spec4.setIndicator("设置");
spec4.setContent(new Intent(this, PanelActivity.class));
host.addTab(spec4);
留言列表