The first step is to create an Android project.
The second step is to modify the generated Res/layout/main.xml
View Plaincopy to Clipboardprint?
android:orientation= "Vertical"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
>
Android:id= "@+id/checkbox"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "check box 1"/>
Android:id= "@+id/checkbox1"
Android:layout_width= "Wrap_content
, the system emits a broadcast with a value of Android.provider.Telephony.SMS_RECEIVED, which is the broadcast to listen to. A Smsbroadcastreceiver instance is then created. Then call the Registerreceiver () method to register the broadcast, where Smsbroadcastreceiver instances and Intentfilter instances are passed in, This way the Smsbroadcastreceiver will receive a broadcast when the system receives the SMS.Note that this inside reads SMS, so need to add read SMS permission. Just add some perm
Android radio to listen to the home button, this way is a better way to use1. Custom Broadcastspublic class Broadcastreceiverex extends broadcastreceiver{string System_reason = "REASON"; String System_home_key = "HomeKey"; String System_home_key_long = "Recentapps"; @Override public void OnReceive (context context, Intent Intent) { String action = intent.getaction ();
Recent projects need to dynamically create a single-selection marquee.The general idea is:1. Dynamically create a radiogroup.2. Create the RadioButton dynamically and add it to the Radiogroup.If you inherit RadioButton, and radiogroup to achieve a variety of other words, accidentally will encounter a variety of diseases.(Ah ah ah, radiogroup I will give you a lot of small monkeys).The most common is the state disorder of RadioButton:(1) A RadioButton is not selected, usually the first one.(2) Ev
Yesterday, suddenly asked to take photos and videos to obtain the time, to get accurate time is generally the time to press the shutter button or press the Stop button to generate the file is more accurate.Because, if you click on the open app to take the photo or video button to get the time, it is necessary and real photo or video time error. Because there is time to load the camera, the focus time, and, after the user enters the photo page, it is possible not to immediately press the shutter
@Override4 protected voidonCreate (Bundle savedinstancestate) {5 Super. OnCreate (savedinstancestate);6 Setcontentview (r.layout.activity_main);7 init ();8 }9 Ten Private voidinit () { OneFindviewbyid (R.id.button). Setonclicklistener (NewView.onclicklistener () { A @Override - Public voidOnClick (View v) { - //the intention here must be to use the same intent as the other Android.intent.action.BOOT_COMPleTED if the use is different, an error wil
Sometimes we need to make a custom radio list, but will encounter some problems, such as multi-choice, false selection problem, so look for information on the Internet, organize a demo out, paste the code:The contents of each row in the listUse a list of pagespublic class Mainactivity extends Activity {private ListView listview;private listviewadapter adapter;private string[] Be ans = new string[] {"1", "2", "3", "4", "5", "6", "7", "8", "9", "Ten", "
has not introduced to everybody to introduce the radio button (Radiogroup) the use, first shows the effect chart for everybody:
XML file
Java files
public class Mainactivity extends activity {private TextView txt=null;
Private Radiogroup Sex=null;
Private RadioButton Male=null;
Private RadioButton Female=null;
@Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);
Setcontentvie
The process of broadcasting events① Register Broadcast event: There are two ways of registering, one is static registration, is defined in the Androidmanifest.xml file, the registered broadcast receiver must inherit Broadcastreceiver, and the other is dynamic registration, is registered in the program using CONTEXT.REGISTERRECEIVER, registered broadcast receiver equivalent to an anonymous class. Both of these methods require intentfilter.② Send broadcast event: sent by Context.sendbroadcast, by
Not much to say, go straight to the car ...1 Public classMyreceiverextendsBroadcastreceiver {2 @Override3 Public voidOnReceive (Finalcontext Context, Intent Intent) {4Alertdialog.builder Builder =NewAlertdialog.builder (context);5Builder.settitle ("Hint");6Builder.setmessage ("OK to open the main interface?") "); 7Builder.setpositivebutton ("OK",NewDialoginterface.onclicklistener () {8 @Override9 Public voidOnClick (Dialoginterface Dialog,intwhich) {TenIntent intent1 =NewInten
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.