AutocompleteTextView

AutocompleteTextView是一种附加提示输入的输入框,不过最少要输入两个字符才会出现提示.
效果如下图所示:
AutocompleteTextView_第1张图片
代码实现:



public class MainActivity extends Activity {
    private ArrayAdapter adapter;
    private AutoCompleteTextView mAutocompleteTextView;
    private String[] array={"view_text","view_edit","view_list","layout_linear","layout_relative","layout_frame","layout_abosolutely","button"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mAutocompleteTextView= (AutoCompleteTextView) findViewById(R.id.autocompletetextview);
        adapter= new ArrayAdapter(this,android.R.layout.simple_list_item_1,array);
        mAutocompleteTextView.setAdapter(adapter);

    }


}

你可能感兴趣的:(Android)