入门的IntelliJ IDEA和Android开发入门

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.


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值