EditText+Button组合自定义视图
来源:互联网 发布:listview数据更新 编辑:程序博客网 时间:2024/06/03 12:52
<?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="wrap_content"> <EditText android:id="@+id/editText" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/clearButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Clear" /></LinearLayout>
package com.paad.views;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.LinearLayout;/** * Listing 4-13: Constructing a compound View */public class ClearableEditText extends LinearLayout { EditText editText; Button clearButton; public ClearableEditText(Context context) { super(context); // Inflate the view from the layout resource. String infService = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater li; li = (LayoutInflater)getContext().getSystemService(infService); li.inflate(R.layout.clearable_edit_text, this, true); // Get references to the child controls. editText = (EditText)findViewById(R.id.editText); clearButton = (Button)findViewById(R.id.clearButton); // Hook up the functionality hookupButton(); } /** * Listing 4-14: Implementing the Clear Text Button */ private void hookupButton() { clearButton.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { editText.setText(""); } }); }}
0 0
- EditText+Button组合自定义视图
- Android自定义组合控件--EditText和Button组合成带有清空EditText内容功能的复合控件
- 自定义Dialog,带textview,EditText,Button
- 自定义Dialog,带textview,EditText,Button
- 001-自定义视图-圆角TextView、ImageView、Button
- EditText,Button
- 使用shape自定义圆角样式的Button和EditText
- android自定义控件(组合控件)--带删除按钮的EditText
- android 自定义组合控件总结(两个Button点击切换)
- <Button>按钮点击变换,<EditText>组建功能,<TditView>文本跑马效果,滚动视图
- TextView、Button、EditText
- TextView EditText和Button
- 1.TextView、EditText、Button
- EditText自定义
- 自定义EditText
- 自定义EditText
- 自定义EditText
- 自定义EditText
- oc面向对象—实例变量以及set get方法
- 手机号码归属地查询api接口
- listview.setSelection ()无效的问题
- Android手机同时使用Wi-Fi和数据流量
- ABC类网络个数的算法
- EditText+Button组合自定义视图
- 如果
- python生成器Generator
- java.lang.ClassNotFoundException web项目加载时找不到类
- 数据有效性跨表引用的解决
- eclipse maven plugin link 插件 安装 和 配置
- 下载地址 集合
- 关于字符编码 g_convert(), g_locale_to_utf8()
- 用MFC实现打开word文件