zoukankan      html  css  js  c++  java
  • Java-Android 之输入提示框

    Android的文本提示框有两种方式:

    main.xml文件

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="模糊查询" />
        <AutoCompleteTextView 
            android:id="@+id/autotext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            
            />
        <MultiAutoCompleteTextView
            android:id="@+id/mull"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />
    
    </LinearLayout>
    

     MainActivity.java文件

    package cn.szy.com;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.ArrayAdapter;
    import android.widget.AutoCompleteTextView;
    import android.widget.MultiAutoCompleteTextView;
    
    public class MainActivity extends Activity {
        /** Called when the activity is first created. */
    	private MultiAutoCompleteTextView move;
    	private AutoCompleteTextView auto;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            auto = (AutoCompleteTextView)this.findViewById(R.id.autotext);
            String [] autoStrings = new String [] {
            		"联合国",
            		"联合军",
            		"联邦"
            };
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_dropdown_item_1line,autoStrings);
            auto.setAdapter(adapter) ;
            move = (MultiAutoCompleteTextView)this.findViewById(R.id.mull);
            move.setAdapter(adapter) ;
            move.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
        }
    }
    
  • 相关阅读:
    免费的数据库建模工具
    [原创]程序设计 异常处理总结
    C#混淆器 xenocode 使用说明
    [转载]Quartz.net官方开发指南 第九课: JobStore
    [转载] Quartz Cron 表达式(时间格式的写法)
    calico+macvlan
    华为欧拉openEuler 更新源没有main路径
    Difference between "genmask" and "netmask"?
    left join、right join和join的区别
    SQL查询时根据类型条件转换
  • 原文地址:https://www.cnblogs.com/sunxun/p/4070814.html
Copyright © 2011-2022 走看看