情景模式截图
Layout布局代码:
activity_main.xml代码
不用编写
activity1.xml代码
<RadioButton
android:id="@+id/r2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/r4"
android:layout_below="@+id/r3"
android:layout_marginTop="40dp"
android:text="振动" />
<RadioButton
android:id="@+id/r1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/r2"
android:layout_alignParentTop="true"
android:layout_marginTop="40dp"
android:text="铃声和振动" />
<RadioButton
android:id="@+id/r3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/r2"
android:layout_below="@+id/r1"
android:layout_marginTop="40dp"
android:text="铃声" />
<RadioButton
android:id="@+id/r4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/r2"
android:layout_marginTop="40dp"
android:text="静音" />
activity2.xml代码
<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="设定时间:"/>
<TimePicker
android:id="@+id/timePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioButton
android:id="@+id/r2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="振动" />
<RadioButton
android:id="@+id/r1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/r2"
android:layout_alignParentTop="true"
android:layout_marginTop="40dp"
android:text="铃声和振动" />
<RadioButton
android:id="@+id/r3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="铃声" />
<RadioButton
android:id="@+id/r4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="静音" />
activity3.xml代码
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="声音模式"/>
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</TableRow>
<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="声音音量" />
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical">
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/stat_sys_download" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/stat_sys_upload" />
</TableRow>
主要代码:
MainActivity.java代码
public class MainActivity extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity1);
TabHost tabhost=getTabHost();
getLayoutInflater().inflate(R.layout.activity_main, tabhost.getTabContentView());
Intent tab1=new Intent();
tab1.setClass(this,Activity1.class);
TabHost.TabSpec tab01 = tabhost.newTabSpec("tab01")
.setIndicator("普通情境模式").setContent(tab1);
Intent tab2=new Intent();
tab2.setClass(this,Activity2.class);
TabHost.TabSpec tab02 = tabhost.newTabSpec("tab02")
.setIndicator("定时情境模式").setContent(tab2);
Intent tab3=new Intent();
tab3.setClass(this, Activity3.class);
TabHost.TabSpec tab03 = tabhost.newTabSpec("tab03")
.setIndicator("自由情境模式").setContent(tab3);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Activity1.java
不用编写
Activity2.java
不用编写
Activity3.java
不用编写
赶快运行一下吧!