当前位置: 首页 > news >正文

做3d人物模型素材下载网站信息流广告素材网站

做3d人物模型素材下载网站,信息流广告素材网站,网站排名不可有利就前,网站制作模板代码今天实现Android里自定义带删除功能的EditText&#xff0c;效果如下&#xff1a; 当输入内容时&#xff0c;EditText变为带有一个删除功能按钮的编辑框&#xff0c;如图&#xff1a; 实现代码很简单&#xff0c;直接上代码, 布局文件xml: 1 <?xml version"1.0" e…

今天实现Android里自定义带删除功能的EditText,效果如下:

 当输入内容时,EditText变为带有一个删除功能按钮的编辑框,如图:

 

实现代码很简单,直接上代码,

布局文件xml:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:background="#000000"
 6     android:orientation="vertical" >
 7 
 8     <LinearLayout
 9         android:layout_width="match_parent"
10         android:layout_height="wrap_content"
11         android:background="@drawable/back" 
12         android:layout_marginBottom="5dp"
13         android:layout_marginLeft="5dp"
14         android:layout_marginRight="5dp"
15         android:layout_marginTop="5dp" >
16 
17         <ImageView
18             android:id="@+id/search_img"
19             android:layout_width="wrap_content"
20             android:layout_height="wrap_content"
21             android:paddingTop="7dp"
22             android:src="@drawable/search" />
23 
24         <EditText
25             android:id="@+id/clearText"
26             android:layout_width="fill_parent"
27             android:layout_height="wrap_content"
28             android:layout_weight="1"
29             android:background="@null"
30             android:hint="搜索"
31             android:imeOptions="actionDone"
32             android:singleLine="true" >
33         </EditText>
34 
35         <Button
36             android:id="@+id/clear_btn"
37             android:layout_width="40dp"
38             android:layout_height="40dp"
39             android:background="@drawable/clear" />
40     </LinearLayout>
41 
42 </LinearLayout>

activity代码:

 1 package com.example.cleartextdemo;
 2 
 3 import android.app.Activity;
 4 import android.os.Bundle;
 5 import android.text.Editable;
 6 import android.text.TextWatcher;
 7 import android.view.View;
 8 import android.widget.Button;
 9 import android.widget.EditText;
10 
11 public class MainActivity extends Activity {
12 
13     private EditText clearEditText;
14     private Button clearbtn;
15 
16     @Override
17     protected void onCreate(Bundle savedInstanceState) {
18         super.onCreate(savedInstanceState);
19         setContentView(R.layout.activity_main);
20 
21         clearEditText = (EditText) findViewById(R.id.clearText);
22         clearbtn = (Button) findViewById(R.id.clear_btn);
23         clearbtn.setOnClickListener(new View.OnClickListener() {
24             @Override
25             public void onClick(View v) {
26                 clearEditText.setText("");
27             }
28         });
29 
30         clearEditText.addTextChangedListener(mTextWatcher);
31 
32     }
33 
34     TextWatcher mTextWatcher = new TextWatcher() {
35 
36         @Override
37         public void beforeTextChanged(CharSequence s, int start, int count,
38                 int after) {
39             // TODO Auto-generated method stub
40 
41         }
42 
43         @Override
44         public void onTextChanged(CharSequence s, int start, int before,
45                 int count) {
46             // TODO Auto-generated method stub
47 
48         }
49 
50         @Override
51         public void afterTextChanged(Editable s) {
52             if (clearEditText.getText().toString() != null
53                     && !clearEditText.getText().toString().equals("")) {
54                 clearbtn.setVisibility(View.VISIBLE);
55             } else {
56                 clearbtn.setVisibility(View.INVISIBLE);
57             }
58 
59         }
60 
61     };
62 
63 }

 运行后输入信息如图:

按下删除控件变为:

 

转载于:https://www.cnblogs.com/benchao/p/5160748.html

http://www.lbrq.cn/news/2721349.html

相关文章:

  • 快站科技是什么互联网营销师考试内容
  • 里面云智能建站上海seo公司排名榜
  • 个人网站模板源码seo课程培训学校
  • 衡水提供网站制作公司哪家专业今日足球最新预测比分
  • 用asp.net 做网站海南网站制作
  • wordpress限制文章发布长春网站优化方案
  • 婚庆公司网站建设方案广告推广公司
  • 建立网站时要采用一定的链接结构可采用的基本方式有百度旧版本
  • 机关公文写作网站江门关键词排名工具
  • wordpress局域网建站免费网站站长查询
  • html5制作网站首页排名第一的助勃药
  • 温州网站关键词排名优化怎么制作个人网页
  • 做党务工作常用到的网站站长工具官网查询
  • wordpress 标签搜索引擎惠州百度seo哪家好
  • 如何拷贝别人网站的源码seo网站编辑优化招聘
  • 大兴网站开发网站建设报价长沙seo优化推广
  • 东莞制作公司网站网推什么意思
  • 企业手机端网站源码下载最佳磁力吧ciliba磁力链
  • 手机网站的价值网站制作步骤流程图
  • 科普网站建设目前最好的营销模式
  • 南阳哪里做网站比较好天津搜索引擎推广
  • 做的网站在百度找不到个人网站模板免费下载
  • 东莞网站建设哪家好提高关键词排名的软文案例
  • 武汉站建设互联网营销师考试
  • 什么程序做网站百度热线客服24小时
  • 网站dns如何修改不了seo视频教学网站
  • 暴雪被谁收购了seo优化行业
  • 营销型网站建设哪好中国网评中国网评
  • 哪个网站可以做pcb加工百度投诉电话客服24小时
  • 标准北京时间久久网枣庄网站seo
  • 云原生俱乐部-k8s知识点归纳(3)
  • CUDA中的基本概念
  • 从源码到可执行文件:hello.c 的二进制之旅
  • 解剖HashMap的put <三> JDK1.8
  • C#WPF实战出真汁01--项目介绍
  • 基于U-NET遥感影像语义分割任务快速上手