码迷,mamicode.com
首页 > 其他好文 > 详细

高级控件 下(一)

时间:2017-05-30 23:17:40      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:tor   use   .com   over   wrap   onclick   iss   ddt   host   

1.计时器(Chronometer)
<!-- 给应用授权:改变震动的权限 -->
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
//取得震动服务
vb=(Vibrator) getApplication().getSystemService(Service.VIBRATOR_SERVICE);
//开始计时
bstart.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ch.start();
vb.vibrate(new long[]{1000,1000,1000,2000}
, 0);
}
});
//停止计时
bstop.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
ch.stop();
ch.setBase(SystemClock.elapsedRealtime());//复原

}
});
2.标签组件方式一(TabHost)
TabHost tabHost=getTabHost();
//把内容XML绑定在tabhost中
LayoutInflater.from(this).inflate(R.layout.tabhost
, tabHost.getTabContentView(),true);
TabSpec ts1=tabHost.newTabSpec("tab1")
.setIndicator("选项一")
.setContent(R.id.tv011);
tabHost.addTab(ts1);

TabSpec ts2=tabHost.newTabSpec("tab2")
.setIndicator("选项二")
.setContent(R.id.tv022);
tabHost.addTab(ts2);

TabSpec ts3=tabHost.newTabSpec("tab3")
.setIndicator("选项三")
.setContent(R.id.tv033);
tabHost.addTab(ts3);

方式二
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<LinearLayout
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:id="@+id/ll1"
>
<TextView 
android:id="@+id/tv044"
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="选项内容一"
android:textSize="20dp"
/>
<ImageView
android:src="@drawable/sss"
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_weight="1"
></ImageView>

</LinearLayout>


</TabHost>

高级控件 下(一)

标签:tor   use   .com   over   wrap   onclick   iss   ddt   host   

原文地址:http://www.cnblogs.com/fxx0129-nn/p/6921664.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!