// Auto-Padded TextView
Autocompletetextview mplace = (autocompletetextview) Findviewbyid (R.ID.AUTOCOMPLETETEXTVIEW1);
string[] books = new string[] {"Rollen", "Allen", "Rollenren", "roll"};
// define an adapter for raw data first
Arrayadapteradapter =new arrayadapter<string>
(mainactivity.this,android. R.layout.simple_dropdown_item_1line,books);
// Set the TextView Adapter
Mplace.setadapter (adapter);
// Enter multiple auto- TextView
Multiautocompletetextviewmtexts = (Multiautocompletetextview) Findviewbyid (R.ID.MULTIAUTOCOMPLETETEXTVIEW1);
// Set the TextView Adapter
Mtexts.setadapter (newarrayadapter<string>
(Mainactivity.this,android. R.layout.simple_dropdown_item_1line,books));
// Set the adapter's separator, such as comma
Mtexts.settokenizer (Newmultiautocompletetextview.commatokenizer ());
// limit the length of characters entered
Finaledittext text_filterred = (EditText) Findviewbyid (R.ID.EDITTEXT1);
Text_filterred.setfilters (newinputfilter[]{
newinputfilter.allcaps (),
Newinputfilter.lengthfilter (2)
});
//button button to implement Activity Jump Pass Parameters
Finalbutton btn = (Button) Findviewbyid (R.id.button1);
Btn.setonclicklistener (Newonclicklistener () {
@Override
publicvoid OnClick (View v) {
intentintent = new Intent ();
Intent.setclass (mainactivity.this,test1activity.class);
Intent.putextra ("str", "come from First activity");
startactivity (intent);
}
});
//checkbox Settings and Response events
Finalcheckbox Check_button = (CheckBox) Findviewbyid (r.id.checkbox1);
Check_button.setonclicklistener (Newonclicklistener () {
@Override
publicvoid OnClick (View v) {
Tx.settext (check_button.ischecked ()? " Selected ":" unchecked ");
}
});
//togglebutton Settings and Response events
Finaltogglebutton ToggleButton = (ToggleButton) Findviewbyid (R.id.togglebutton1);
Togglebutton.setoncheckedchangelistener (Newoncheckedchangelistener () {
@Override
publicvoid oncheckedchanged (Compoundbutton buttonview,boolean isChecked) {
tx.settext (isChecked? " ) Selected ":" unchecked ");
}
});
// radio button radiogroup settings and Response events
Finalradiogroup Group = (radiogroup) Findviewbyid (r.id.radiogroup1);
// Clear Selection
Group.clearcheck ();
Group.setoncheckedchangelistener (Newradiogroup.oncheckedchangelistener () {
@Override
publicvoid oncheckedchanged (radiogroup Group, int checkedid) {
if (checkedid!=-1) {
RADIOBUTTONRB = (RadioButton) Findviewbyid (checkedid);
if (rb!=null) {
Tx.settext ("Youchose:" +rb.gettext ());
}
}
}
});
// drop-down list Spinner settings and Response events
<spinner
android:id= "@+id/spinner1"
android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:entries= "@array/colors"
android:prompt= "@string/spin_prompt"/>
Use the contents of the array to specify the Spinner data source
Spin= (Spinner) Findviewbyid (r.id.spinner1);
Spin.setonitemselectedlistener (Newonitemselectedlistener () {
@Override
publicvoid onitemselected (adapterview<?> arg0, View arg1,
intarg2, Long Arg3) {
textviewtvn= (TextView) arg1;// get the TextView
if (tvn!=null) {
Tx.settext (Tvn.gettext (). toString ());
}
}
@Override
publicvoid onnothingselected (adapterview<?> arg0) {
//todo auto-generated Method Stub
}
});
Android Basic Controls use