Android Study Notes (4): Do not use the IDE command line

Source: Internet
Author: User

Here, we do not use IDE and directly use the command line for processing.

1. Create a project

Here we use the commands in tools in andriod SDK:

Android Create project -- Target 2/
-- Path/workspace/andriod/learning/now -- activity now/
-- Package com. Wei. andriod. Learning. Now

2. Programming

In the src/COM/Wei/andriod/learning/now/directory on now. Java, This is the activity we need to process. In this example, we create a button to display the time when the button was last pressed or the time it was used to start ing.

Package com. Wei. andriod. Learning. now;

Import Android. App. activity;
Import Android. OS. Bundle;
Import Android. View. view;
Import Android. widget. Button;
Import java. util. date; // note that not all Java classes are valid in andriod. You can view andriod class reference.

// In andriod. in the view package, View. onClickListener is a public static interface which definition for a callback to be invoked when a view is clicked by an abstract void on Click (View v) method.
Public class Now extends Activity implements View. OnClickListener
{
Button button;

/** Called when the activity is first created.
* When activity start is enabled, onCreate is called first.
*/
@ Override
Public void onCreate (Bundle savedInstanceState)
{
/* First run the related initial processing of the parent class Activity onCreate */
Super. onCreate (savedInstanceState );

/* Create a button instance. When you click a button, call the onclick processing method of this instance. In this instance, we implement the view. onclicklistener interface. This is different from swing in Java. During jbutton click, actionevent events are often passed to actionlistener, and the processing method here is more to VC, through the onclicklistener instance, the onclick () method that triggers the onclick () method. */
Button = new button (this );
Button. setonclicklistener (this );
Updatetime ();
Setcontentview (button );
}

Public void onclick (view ){
Updatetime ();
}

Private void updatetime (){
Button. settext (new date (). tostring ());
}
}

3. Compile

Compile: ant1.8 is required, and the version is not enough. So apt-Get install ant1.8 is run.$ Ant debug

4. Load

Run the andriod command to open our simulator and install the following on the simulator:$ Ant installThen we can see our application now on the simulator and run it.

Related links:
My andriod development articles

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.