入门的IntelliJ IDEA和Android开发入门

来源:互联网 发布:java微信公众开源框架 编辑:程序博客网 时间:2024/06/07 20:02

Getting Started with IntelliJ IDEA and Android Development

Download IntelliJ IDEA

If you don't already have IntelliJ IDEA installed, you can download a 30-day evaluation version from http://www.jetbrains.com/idea/download/

The plugin requires IntelliJ IDEA 7.0 or higher and is not compatible with earlier versions of IntelliJ IDEA.

Install Plugin

Go to Settings | Plugins, select the "Android Support" plugin in the Available tab and press Install.

Create New Project

Select "Create project from scratch" option. On the second page of the wizard, enter the name and location of your project.

Accept the default source root option. On the "Technologies" page, select Android and enter the path to your Android SDK installation.

If you are prompted to select a JDK, select the installation home of a Java 1.5 or 1.6 JDK (no JRE).

Create Activity

Select the src directory in the project view, press Alt-Ins (Ctrl-Enter on a Mac) to invoke the "New" menu and select "Package". Enter the name of the package.

Select the package, press Alt-Ins again and select "Activity" from the menu.

In the "New Activity" dialog, enter the class name and label for the activity. Ensure that "Mark as startup activity" checkbox is checked.

Create Activity Implementation

In the activity class, press Ctrl-O to invoke the "Override Methods" dialog. Select the onCreate method.

Type the method body text:

    protected void onCreate(Bundle bundle) {        super.onCreate(bundle);        TextView tv = new TextView(this);        tv.setText("Hello, Android, from IntelliJ IDEA!");        setContentView(tv);    }

Run the Activity

Right-click the class and select "Run HelloWorld" from the context menu.

Wait for the emulator to start, and for the activity to be displayed.

If an error "Cannot start activity..." is printed in the console window, close the emulator and try again (this is a known issue with the Android emulator).

Note that the initial release of the plugin does not support debugging Android applications. Debugging support will be added in a future release.

Cool Stuff to Try

(a.k.a. why we're better than ADT :) )

In AndroidManifest.xml, put the cursor on @drawable/icon and press Ctrl-Shift-I.

Try pressing Ctrl-B and Ctrl-Space in a few places to explore the navigation completion options available. Even in the initial release of the plugin, a few things are supported.


原创粉丝点击