高级控件

自动完成文本(AutoCompleteTextView)

自动完成文本用于实现允许用户输入一定字符后,显示一个下拉菜单,提供用户从中选择,当用户选择某个选项后,按用户选择自动填写该文本框。AutoCompleteTextView继承自EditText,所以它支持EditText提供的属性,同时 ,它还支持其他一些属性。



进度条(ProgressBar)

当一个应用程序在后台执行时,前台界面不会有任何信息,这时用户根本不知道程序是否在执行以及执行进度等,因此需要使用进度条来提示程序执行的进度。在Android中,进度条用于向用户显示某个耗时操作完成的百分比。
进度条支持的属性:
1.android:max   用于设置进度条的最大值。
2.andorid:progress   用于指定进度条已完成的进度值
3.android:progressDrawable   用于设置进度条轨道的绘制形式
除了以上的属性之外,进度条组件还提供了下面两个常用方法用于操作进度。
1.setProgress(int progress)方法:用于设置进度完成的百分比
2.incrementProgress(int diff)方法:用于设置进度条的进度增加或减少。当参数值为正数时,表示进度增加;为负数时,表示进度减少。


如下为一个xml文件中的一个进度条例子:


<ProgressBar 
        	android:id="@+id/progress_bar"
       	 	android:layout_width="fill_parent"
        	android:layout_height="wrap_content"
        	android:max="100"
        	style="@android:style/Widget.ProgressBar.Horizontal"/>
其中style属性用来指定进度条的风格,一下为一些常用的style属性值:
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context=".MainActivity" >

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
        <TabWidget 
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        </FrameLayout>
    </LinearLayout>

</TabHost>