About Android Button Response page Jump issue

Source: Internet
Author: User

In general, Button response events inAndroid applications are written in two ways

Button Button=null;

Button.setonclicklistener (New Buttononclicklistener ());

Then write a listener's inner class

Class Buttononclicklistener implements Onclicklistener {

public void OnClick (View v) {
Intent Intent = new Intent ();
Intent.setclass (the current class name . This, jump to the class . Class);
StartActivity (Intent);
}

}

This is the first one, the second of which is as follows

Button.setonclicklistener (New View.onclicklistener () {
public void OnClick (View v) {

Intent Intent = new Intent ();
Intent.setclass (the current class name . This, jump to the class . Class);
StartActivity (Intent);

}

});

When the code check is not wrong, run an error, the following prompt

Many students can not find the reason, the reason is very simple, is to register the corresponding Activity class in the androidmanifest.xml , this kind of covert registration beginner is easy to commit

The specific syntax is <activity name= ". Corresponding class name" ></Activity>


In addition, if you do not specify a good application SDK version, in fact, many of the online simple case source code does not fill out the SDK version. Import into Eclipse The program will explode a lot of red light, the basic error of an R class, in fact, the R class is automatically generated by the system, do not write their own. It 's also easy to set the SDK version

Find androidmanifest.xml, open with mainfest , click Uses Sdk


Min SDK version is the Set app support minimum Android SDK release, 9 for Android 2.3. 8 corresponds to Android2.2, more than 4 of Android can support more than 95%.

Target SDK Versioin is to set your current Android version, Android4.2.2 corresponds to 17,android 4.3 corresponding to 18,android l corresponding 20, set according to the circumstances

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.