android:TextView相关使用问题

1、TextView的Layout属性:

      wrap_content:包裹实际文本内容;

      match_parent:当前控件铺满父类容器,2.3API之后

      fill_parent:当前控件铺满父类容器,2.3API之前

2>、TextView的跑马灯效果实现

   1、实现4个属性:

       android:singleLine = "true"
        android:ellipsize="marquee"
        android:focusable="true"
        android:focusableInTouchMode="true"

     2、创建一个继承TextView的子类
      //添加构造函数 Source --> Generate Constructors from Superclass
     public class MarqueeText extends TextView {
          public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
               super(context, attrs, defStyle);
               // TODO Auto-generated constructor stub
           }
         public MarqueeText(Context context, AttributeSet attrs) {
                  super(context, attrs);
                  // TODO Auto-generated constructor stub
           }
         public MarqueeText(Context context) {
              super(context);
              // TODO Auto-generated constructor stub
          }
        @Override
         public boolean isFocused() {
           return true;
         }

   4、修改TextView的引用:<com.example.textview.MarqueeTex

2>、AutoCompleteTextView实现自动匹配输入内容 

         //第一步:初始化控件
        //第二步:需要一个适配器
        //第三步:初始化数据源  -- 这数据源去匹配文本框中的数据
        //第四步:讲adpter与当前autoCompleteTextView进行绑定
        acTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, res);
        acTextView.setAdapter(adapter);

        private AutoCompleteTextView acTextView;
        private String[] res = {"beijing1", "beijing2", "beijing3", "shanghai"};

          android:completionThreshold="3" //输入几个开始自动匹配

3>、 MultiAutoCompleteTextView  可支持选择多个值得匹配,分别用分隔符分开,比如输入邮件
        独特属性:设置分隔符的样式  mtxt.setTokenizer(new MultiAutoCompleteTextView.Commatokenizer());


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值