1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
public class AutoComplet extends Activity implements TextWatcher{
/** Called when the activity is first created. */
public static final String[] CARS = {"Alfa Romeo","Audi", "Austin" , "BMW", "Cadillac"
, "Chevrolet", "Chrysler", "Citroen", "Daewoo", "Daihatsu", "Dodge", "Fiat", "Ford"
, "Honda", "Hyundaï", "Isuzu", "Iveco", "Jaguar", "Jeep", "Kia", "Lancia"
, "Land Rover", "Lexus", "Ligier", "Lincoln", "Mazda", "Mercedes", "MG"
, "Mini", "Mitsubishi", "Nissan", "Opel", "Peugeot", "Porsche", "Renault", "Rover"
, "Saab", "Seat", "Skoda", "Smart", "SSangyong", "Steyr-Puch", "Subaru", "Suzuki"
, "Toyota", "Triumph", "TVR", "Volvo", "VW"
};
TextView textView;
//jEditText editText;
AutoCompleteTextView auto;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//editText = (EditText) findViewById(R.id.EditText01);
//editText.setText("");
auto = (AutoCompleteTextView) findViewById(R.id.AutoCompleteTextView01);
auto.setText("");
//editText.addTextChangedListener(this);
auto.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, CARS));
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
auto.setText(auto.getText());
}
} |
Partager