AutocompleteTextView: esempio semplice utilizzo – Android

Questo esempio mostra come utilizzare l’AutocompleteTextView utile per facilitare l’immissione di un testo predefinito nella TextView

import java.util.Vector;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

public class Prova extends Activity {

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

    	Vector name=new Vector();
    	name.add("Mario Rossi");
    	name.add("Francesco Verdi");
    	name.add("Pino Giallo");
    	name.add("Giulia Blu");

        ArrayAdapter adapter = new ArrayAdapter(this,
                android.R.layout.simple_dropdown_item_1line, name);
        AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.AutoCompleteTextView01);
        textView.setAdapter(adapter);
    }
}

Scarica l’esempio:[download id=”2″]


Lascia un commento