Android Event Encyclopedia

Source: Internet
Author: User

1 Onclicklistener (Click event)
Component. Setonclicklistener (new Onclicklistener () {
public void OnClick (View v) {
String str = Et.gettext (). toString ();
Tv.settext (str);
}
});

2 Oncheckedchangelistener (single selection changes)
Rg.setoncheckedchangelistener (New Oncheckedchangelistener () {
public void OnCheckedChanged (
Radiogroup Group, int checkedid) {
RadioButton RB = (RadioButton)
Findviewbyid (Checkedid);
String str = Rb.gettext (). toString ();
Tv.settext (str);
}
});


3 Onitemselectedlistener (drop-down list)
Sp.setonitemselectedlistener (New Onitemselectedlistener () {
public void onitemselected (adapterview<?> arg0, view view,
int arg2, long arg3) {
TextView TV1 = (TextView) view;
String str = Tv1.gettext (). toString ();
Tv.settext (str);
}

public void onnothingselected (adapterview<?> arg0) {
}
});

4 Ontimechangedlistener Time Event monitoring

5 Onfocuschangelistener Focus Event
Et.setonfocuschangelistener (New Onfocuschangelistener () {
public void Onfocuschange (View V, Boolean hasfocus) {
if (Hasfocus) {
Et.settext ("");
}else{
String str= Et.gettext (). toString ();
Tv.settext (str);
}
}
});


6 Ondatechangelistener
Dp.init (4, Ondatechangedlistener, new) {
public void ondatechanged (DatePicker view, int year, int monthofyear,
int DayOfMonth) {
Tv.settext (year+ "-" +monthofyear+ "-" +dayofmonth ");
}
});

7 Onlongchangelistener (Long press event)
<!--settings to modify desktop background permissions--
<uses-permission android:name= "Android.permission.SET_WALLPAPER"/>
Iv.setonlongclicklistener (New Onlongclicklistener () {
public boolean Onlongclick (View v) {
try {
Day07.this.clearWallpaper ();
Getresources ();//Get Resource Object
InputStream data = Getresources (). Openrawresource (R.DRAWABLE.A);
Day07.this.setWallpaper (data);
} catch (IOException e) {
E.printstacktrace ();
}
return false;
}
});

Android Event Encyclopedia

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.