自动链接、自动完成输入框、开关按钮和单选、多选按钮的简单使用
2013-06-10 15:05
447 查看
下面介绍了几个简单的组件
AutoCompleteTextView 自动完成输入框
AutoLink 自动链接
ImageButton 图片按钮
ToggleButton 开关按钮
CheckBox 复选框
RadioButton 单选按钮
RadioGroup 控制单选
java代码:
xml文件:
AutoCompleteTextView 自动完成输入框
AutoLink 自动链接
ImageButton 图片按钮
ToggleButton 开关按钮
CheckBox 复选框
RadioButton 单选按钮
RadioGroup 控制单选
java代码:
import com.lovo.R; import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; public class ContentActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.content_main); /** * 自动完成输入框 */ String [] ary = new String[]{ "lovo","love","abcd","zhang","xiao" }; //创建数组适配器 //参数2:android内部提供的下拉列表样式 ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, ary); AutoCompleteTextView autoText = (AutoCompleteTextView) findViewById(R.id.autoText); //将设配器加入到自动完成组件中 autoText.setAdapter(adapter); } }
xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:autoLink="web" android:text="网址:http://www.baidu.com" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:autoLink="email" android:text="email:abc@sina.com" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:autoLink="all" android:text="电话:13888888888" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="25dp" android:password="true" /> <AutoCompleteTextView android:id="@+id/autoText" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_launcher" android:text="确定" > </Button> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> <!-- 开关按钮 --> <ToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:textOff="×" android:textOn="√" /> <LinearLayout
android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="成都" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="上海" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="北京" /> </LinearLayout> <RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="男" /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="女" /> </RadioGroup> </LinearLayout>
相关文章推荐
- datagrid的几点简单应用,功能包括radio的单选,checkbox的多选,鼠标移动到行上颜色变深,链接传递多参数等功能。这里radio和checkbox都使用的是HTML控件。
- Angular-UI自动完成输入框AutoComplete[项目中使用]
- MLPAutoCompleteTextField 带有可自动完成的下拉菜单 简单使用
- android自动完成文本 和 单选按钮
- jQuery中使用Ajax实现文本输入框的自动完成功能
- 简单的单选多选按钮
- android简单实例--------------------3种特殊dialog的使用,单选、多选、适配器dialog对话框
- Android -- 对话框 Dialog: 确定取消,单选多选,进度显示, 常用控件示例:单选多选框,下拉列表,进度条,自动完成文本框, 菜单显示
- 5. 在cocos2d里面如何制作按钮:简单按钮、单选按钮和开关按钮
- RadioGroup、RadioButton(单选按钮)、CheckBox(多选按钮)和Toast的使用方法
- (译)在cocos2d里面如何制作按钮:简单按钮、单选按钮和开关按钮
- Ionic中单选按钮radio的简单使用
- Silverlight AutoCompleteBox(自动完成输入框控件)使用方法
- AngularJS中单选按钮radio的简单使用
- Silverlight AutoCompleteBox(自动完成输入框控件)使用方法
- UICollectionView使用storyBoard完成设置自动布局,并附带简单选择功能
- MFC中单选按钮(Radio Button)的简单使用
- 在cocos2d里面如何制作按钮:简单按钮、单选按钮和开关按钮
- 状态开关按钮ToggleButton的简单使用:实现动态控制布局
- 在cocos2d里面如何制作按钮:简单按钮、单选按钮和开关按钮