隨筆提示文本

1. Demo.javajava

public class Demo extends AppCompatActivity {
    private static final String DATA[] = new String[] {
          "hello","hello ok","hello nihao","hello waitting","hello banana"  //自動提示信息
    };
    private AutoCompleteTextView myauto = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress_activity_demo);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line,DATA);
        this.myauto = (AutoCompleteTextView)super.findViewById(R.id.myauto);
        this.myauto.setAdapter(adapter);
    }
}

2.  activity_demo.xml  自動填充文本android

<AutoCompleteTextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/myauto"/>
相關文章
相關標籤/搜索