Android Tips (2)

Source: Internet
Author: User
Tags response code

1) Create a Android Project

Fill in the project information

2) Create a new Activity

Right click on the left side of Eclipse (default) you want to join the activity package, for example, my package is com. Indroid.layout. Then select New->class, enter the class name (note the first letter capitalized), and click on Superclass's Browse. Finally, enter activity in choose a type. And then you can just click OK.

3) create Activity layouts

Create a layout XML page in the Rec/layout folder new->others->android->android XML file

4) Register the created activity to androidmanifest.xml

Use Eclisps to visualize the Add, double-click androidmanifest.xml Select Label Application->add->activity, enter the class name you just created.

Can also be added manually, under the </activity> tag

<activity android:name= ". New Activity 's name "

android:label= " New Activity the title ">

</activity>

It is important to note that the android:name= "." Here's a point, which means the activity is under the com.INdroid.layout of the package I've chosen.

5) Add the OnCreate method to the new activity and bind layout.

On the activity jump problem, to add that the button binding Setonclicklistener must be placed after the new Onclicklistener object, or not jump.

In this, an activity that can be used is created, and the next step is to add UI elements and implement the page response code

The following is an example of adding a checkbox, the effect is to click on the main activity interface, jump to the Checkboxactivity interface

1. Add a button to the main activity interface. Open main: XML, using the "+" of the outline window, add a button to fill in the button's properties

2, in the Src/activitymain class, that is, the main activity of the interface response class to implement the page jump code,

2.1 Declaring the button variable and listener Onclicklistener

2.2 Implement the Onclicklistener listener's jump logic, that is, the ONCLIHCK function

2-3 binding listener Onclicklistener to button

3. Add a checkbox widget to the Checkboxactivity interface

4. Add rendering code to the Checkboxactivity interface

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.