• android_MultiAutoCompleteTextView


    package cn.com.sxp;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.ArrayAdapter;
    import android.widget.Button;
    import android.widget.MultiAutoCompleteTextView;

    public class MultiAutoActivity extends Activity {
    private MultiAutoCompleteTextView autoCom = null;;
    private Button btnClear = null;
    private String[] normalString = null;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    normalString = new String[] { "android", "android sxp", "sxp", "sxp wx"};

    autoCom = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView);
    btnClear = (Button) findViewById(R.id.btn);

    // simple_dropdown_item_1line
    // android 简单的一些样式,貌似是自定义的
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    android.R.layout.simple_dropdown_item_1line, normalString);

    autoCom.setAdapter(adapter);

    // setTokenizer();
    // Sets the Tokenizer 标记生成器 that will be used to determine the relevant range of the text where the user is typing.
    // CommaTokenizer():
    // 这个简易的组件可以用于一些列表中,这些列表包含被逗号以及一个或数个空格断开的项目。
    // 不太理解,这个方法不加的话没法自动完成文本;添加的话又觉得是废话,列表当然以逗号分隔了
    autoCom.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

    btnClear.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    autoCom.setText("");
    }

    });
    }
    }
  • 相关阅读:
    MYSQL索引
    列表里重复次数最多的元素
    python学习笔记
    Spark 扫描 HDFS lzo/gz/orc异常压缩文件
    Yarn RM写ZNode超数据量限制bug修复
    Spark HistoryServer日志解析&清理异常
    【Yarn源码分析】Container启动流程源码分析
    Yarn NodeManager总体架构
    【Yarn源码分析】ApplicationMaster源码分析
    【Yarn源码分析】FairScheduler资源调度
  • 原文地址:https://www.cnblogs.com/itblog/p/7236626.html
Copyright © 2020-2023  润新知