android--picture View (ImageView), Status switch button (ToggleButton), clock, picture transparency, scrolling, and time picker

Source: Internet
Author: User

Activity_ui1.xml

dth= "wrap_content" android:layout_height= "wrap_content" android:texton= "" android:textoff= "" android:background= "@drawable/qq" android:id= "@+id/tob1"/><AnalogClockAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" />    <DigitalClockAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" />    <DatePickerAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:startyear= "$"Android:endyear= " "android:mindate= "1/1/2000"android:maxdate= "12/31/2016"Android:id= "@+id/dp_1"Android:calendarviewshown= "false"Android:spinnersshown= "false">        <!--StartYear Select Start year endyear Select End year mindate start time MaxDate end Time Calendarviewshown calendar is displayed only for version 4 function Spinnersshown whether to pull down -    </DatePicker>    <TimepickerAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:id= "@+id/tp_1">    </Timepicker>    <!--analogclock Clock dial digitalclock digital clock DatePicker date selector timepicker time selector calendarview Show calendar version 4 not supported  -    <CalendarViewAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"Android:firstdayofweek= "1">    </CalendarView></LinearLayout></ScrollView>

Qq.xml in the drawable directory

<?XML version= "1.0" encoding= "Utf-8"?><selectorxmlns:android= "Http://schemas.android.com/apk/res/android">    <Itemandroid:drawable= "@drawable/on"android:state_checked= "true"/>    <Itemandroid:drawable= "@drawable/off"android:state_checked= "false"/>    </selector>

Uiactivity1.java

 PackageCom.hanqi.application3;Importandroid.app.Activity;ImportAndroid.os.Bundle;Importandroid.support.annotation.IdRes;ImportAndroid.widget.CheckBox;ImportAndroid.widget.CompoundButton;ImportAndroid.widget.DatePicker;ImportAndroid.widget.ImageView;ImportAndroid.widget.RadioButton;ImportAndroid.widget.RadioGroup;ImportAndroid.widget.Switch;ImportAndroid.widget.TimePicker;ImportAndroid.widget.Toast;ImportAndroid.widget.ToggleButton;Import Staticandroid.widget.compoundbutton.*; Public classUIActivity1extendsActivity {ImageView IV; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.LAYOUT.ACTIVITY_UI1); Radiogroup Radiogroup=(Radiogroup) Findviewbyid (R.ID.RB); Radiogroup.setoncheckedchangelistener (NewRadiogroup.oncheckedchangelistener () { Public voidOnCheckedChanged (Radiogroup Group, @IdResintCheckedid) {                if(Checkedid = =r.id.rb3) {toast.maketext (UIActivity1. This, "the right choice.", Toast.length_short). Show (); } RadioButton RB=(RadioButton) Findviewbyid (Checkedid); Toast.maketext (UIActivity1. This, Rb.gettext (), Toast.length_short). Show ();        }        }); CheckBox Cb_st=(CheckBox) Findviewbyid (R.id.cb_st); Cb_st.setoncheckedchangelistener (NewCboncheckchangelistenter ()); CheckBox Cb_xt=(CheckBox) Findviewbyid (R.ID.CB_XT); Cb_xt.setoncheckedchangelistener (NewCboncheckchangelistenter ()); CheckBox CB_JC=(CheckBox) Findviewbyid (R.ID.CB_JC); Cb_jc.setoncheckedchangelistener (NewCboncheckchangelistenter ()); CheckBox Cb_xhx=(CheckBox) Findviewbyid (R.ID.CB_XHX); Cb_xhx.setoncheckedchangelistener (NewCboncheckchangelistenter ()); IV=(ImageView) Findviewbyid (R.ID.IV); ToggleButton Tob=(ToggleButton) Findviewbyid (R.id.tob); Tob.setoncheckedchangelistener (NewToncheckchangelitenter ()); Switch SW=(Switch) Findviewbyid (R.ID.SW); //InitializeDatePicker dp_1=(DatePicker) Findviewbyid (r.id.dp_1); //the month is starting from 0Dp_1.init (2000, 1, 1,NewDatepicker.ondatechangedlistener () {@Override Public voidOndatechanged (DatePicker view,intYearintMonthofyear,intdayofmonth) {Toast.maketext (UIActivity1). This, year+ "-" + (monthofyear+1) + "-" +DayOfMonth, Toast.length_short). Show ();        }        }); Timepicker tp_1=(Timepicker) Findviewbyid (r.id.tp_1); Toast.maketext (UIActivity1. This, dp_1.getyear () + "-" + (Dp_1.getmonth () +1) + "-" +Dp_1.getdayofmonth ()+ "" +tp_1.gethour () + ":" +Tp_1.getminute (), Toast.length_short). Show (); Tp_1.setontimechangedlistener (NewTimepicker.ontimechangedlistener () {@Override Public voidOntimechanged (Timepicker view,intHourofday,intminute) {Toast.maketext (UIActivity1). This, hourofday+ ":" +minute, Toast.length_short). Show ();    }        }); }    Private classToncheckchangelitenterImplementsOncheckedchangelistener { Public voidOnCheckedChanged (Compoundbutton Buttonview,BooleanisChecked) {            if(isChecked) {iv.setimageresource (R.drawable.open); }            Else{iv.setimageresource (r.drawable.close); }        }    }    Private classCboncheckchangelistenterImplementsOncheckedchangelistener {@Override Public voidOnCheckedChanged (Compoundbutton Buttonview,BooleanisChecked) {CheckBox CB=(CheckBox) Buttonview; if(isChecked) {toast.maketext (UIActivity1. This, "Checked", Toast.length_short). Show (); }            Else{toast.maketext (UIActivity1). This, "Canceled.", Toast.length_short). Show (); }        }    }}

android--picture View (ImageView), Status switch button (ToggleButton), clock, picture transparency, scrolling, and time picker

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.