android textview edittext,Android-TextView-EditText笔记

一.TextView

1.属性XML

...

android:ellipsize="marquee" 文本超长时的省略(ellipsis)类型

android:scrollbars = "vertical" 设置滚动条

android:maxLines = "AN_INTEGER" 设置最大行数

android:focusable="true"

.../>

2.显示内容

TextView.setText(Spannable)

Html.formHtml(..) 支持部分HTML标记转为Spannable对象

new SpannableString(..) 支持各种文本样式/图片显示

new SpannableBuilderString(..) 可变长的SpannableString

3.移动方法

TextView.setMoveMethod(MovementMethod)

LinkMovementMethod Html链接跳转

ArrowKeyMovementMethod 光标移动选择

ScrollingMovementMethod 文本内容滚动(配合android:scrollbars使用)

二.EditText 继承自TextView

1.输入表情

SpannableString ss = new SpannableString("表情");

ss.setSpan(new ImageSpan(this,BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher)),

0,2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

editText.append(ss);

2.输入类型

...

android:inputType="textMultiLine|number"

.../>

// 输入错误提示以及图标

editText.setError("错误提示",getResources().getDrawable(R.mipmap.ic_launcher));

3.自动提示输入

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/autoCompleteTextView"/>

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:id="@+id/multiAutoCompleteTextView" />

// 单个输入自动提示

AutoCompleteTextView auto = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);

auto.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1,

new String[]{"Belgium", "France", "Italy", "Germany", "Spain"}));

// 多个输入自动提示

MultiAutoCompleteTextView mulAuto = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView);

mulAuto.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1,

new String[]{"Belgium", "France", "Italy", "Germany", "Spain"}));

mulAuto.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); // 逗号分隔多个输入

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值