随笔提示文本

1. Demo.java

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  自动填充文本

<AutoCompleteTextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/myauto"/>


你可能感兴趣的:(随笔提示文本)