Finish the text box on your own initiative (AutoCompleteTextView)

java.lang.Object;

android.view.View;

android.view.TextView;

android.widget.EditText;

android.widget.AutoCompleteTextView;

MultiAutoCompleteTextView;

AutoCompleteTextView Class method

AutoCompleteTextView Demo sample

complete project:http://download.csdn.net/detail/sweetloveft/9408072

In the following procedure, we mainly learn AutoCompleteTextView Usage of , This control cannot be specified in a layout file android:entries, I didn't check whether there was any other specified method , So we decided to use code loading . There's one more thing to note layout in <requestFocus /> Use .

1.MainActivity.java

package com.sweetlover.activity;
import com.sweetlover.autocompletetextviewdemo.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView; public class MainActivity extends Activity { private static final String[] phoneNumber = new String[]{
"111234", "133126", "303404", "796863"
}; private AutoCompleteTextView autoTextView = null; @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, phoneNumber);
autoTextView = (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
autoTextView.setAdapter(adapter);
}
}

2.activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
android:orientation="vertical" > <AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:hint="@string/note"
android:ems="20" > <requestFocus />
<!-- http://zhangkun716717-126-com.iteye.com/blog/802201 -->
</AutoCompleteTextView> </LinearLayout>

3.string.xml

<resources>
<string name="app_name">AutoCompleteTextViewDemo</string>
<string name="note"> Enter the phone number </string> </resources>

4.AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sweetlover.autocompletetextviewdemo"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="com.sweetlover.activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application> </manifest>

read 《Android From entry to mastery 》(12)—— Take the initiative to finish more related articles in the text box

  1. Android Development series ( twenty ):AutoCompleteTextView( Finish the text box on your own initiative ) Function and usage of

    When the user enters a certain character , The text box can display a drop-down menu when you finish your own initiative , For users to choose from , When the user selects a menu item ,AutoCompleteTextView You can fill in the text box according to the user's choice AutoCo ...

  2. Android From entry to mastery pdf+ Book source code

    There's no need to integrate , Free delivery Android From beginners to proficient pdf, A good book for beginners , because csdn The file size limit is therefore divided into two parts . part1 Address :http://download.csdn.net/detail/a ...

  3. android Pop up the soft keyboard to block EditText Text box solutions

    1.android Pop up the soft keyboard to block EditText Text box solutions : hold Activit The corresponding layout file filename.xml The controls in the file are laid out with specific gravity .( for example :android:layout_wei ...

  4. Android Self active prompt text box (AutoCompleteTextView)

    Self active prompt text box (AutoCompleteTextView) To enhance the user experience , Shorten user input time ( Baidu's search box is this effect ). First . stay xml In the definition of AutoCompleteTextView Control : a ...

  5. Android Volley Beginner to master : Use Volley Load network pictures

    In the last article , We get it Volley What is it , And its basic usage . In this article we are going to learn about Volley More advanced usage , If you haven't read my last article , It is suggested to read first Android Volley End ...

  6. read 《Android From entry to mastery 》(9)—— Multiple choice

    Multiple choice (CheckBox) CheckBox Class is Button Subclasses of , Hierarchical relationships such as the following : android.widget.Button android.widget.CompoundButton ...

  7. read 《Android From entry to mastery 》(17)—— Progress bar

    Progress bar (ProgressBar) java.lang.Object; android.view.View; android.widget.ProgressBar; ProgressBar Class method Pr ...

  8. read 《Android From entry to mastery 》(24)—— Switch pictures

    Switch pictures (ImageSwitcher) java.lang.Object; android.view.View; android.widget.ViewGroup; android.widget.Fr ...

  9. read 《Android From entry to mastery 》(33)——Intent classification

    Intent classification Explicit Intent:Intent("android.intent.action.CALL", Uri.parse("tel:" + stri ...

Random recommendation

  1. MySQL Start error checking

    In general mysql It's easy to check the startup error of , But today, let's talk about the unusual situation . Get a server , installed mysql And then start up , The startup error is as follows : Some students will say , Man, are you buffer pool Set too large ...

  2. UNIX User identification of basic knowledge

    One . user ID Password file (/etc/passwd) The user in the login ID(user ID) It's a number , It identifies different users to the system . System administrators determine a user's login name while , Identify its users ID. Users cannot change their users ID ...

  3. Share 10 individual Js A small library of , The effect is really great

    1.$fx() brief introduction :$fx() It's a lightweight animation library , Some complicated animations , It can be combined by several simple animation effects , But what's provided is obfuscated compressed code , For the research of animation source friends may be particularly unhappy API:http://fx.ine ...

  4. C# establish Windows Service and installation - The illustration

    1. establish windows Service project

  5. cron Timing task

    cron yes linux Next scheduled task : M H D m d cmd.   This is a kind of cron File format .   M: minute (0-59). H: Hours (0-23). D: God (1-31). m: month (1-12). d ...

  6. One way circular list C Language implementation

    We all know , One way linked list finally points to NULL, That is to say, it is empty , The one-way circular list does not point to NULL 了 , Point to the head node , So the result of this program is , You will see that traversing the linked list is a dead loop , Because it doesn't point to NULL, It's also ...

  7. About Chinese kitchen knives , how &quot; Chopping vegetables &quot;

    Introduce Classic title party , Chinese kitchen knives have been analyzed by Daniel -> Portal (http://blog.csdn.net/p656456564545/article/details/49671829). Blogger PHP Rigid contact ...

  8. yii2 gridview checkbox

    to checkbox( stay GridView Inside ) Add one value controller :$dataProvidermStu->key = "student_no"; view:[ 'clas ...

  9. 2.04-proxy-handler

    import urllib.request def create_proxy_handler(): url = "https://blog.csdn.net/m0_37499059/arti ...

  10. Windowsx64 Bit installation pymssql And complete the link with the database

    The normal process just needs to open the download and install it in the normal way mssql The package is in the program import pymssql, But installation mssql There's a little bit of trouble . Since the beginning of the installation, there have been various abnormal errors First sqlfront.h File not found ...