Intellij IDEA开发第一个Android应用
1、创建一个项目
File——>New Project——>.......——>Finish

2、创建模块


3、MyActivity.java
package com.example.myapp;
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MyActivity extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onMyButtonClick(View view){
Toast.makeText(this,"你好!", Toast.LENGTH_SHORT).show();
}
public void onMyButton2Click(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this);
builder.setTitle("标题");
builder.setPositiveButton("确定",null);
builder.setIcon(android.R.drawable.ic_dialog_info);
builder.setMessage("简单消息框");
builder.show();
}
}
4、layout——>main.xml (布局文件)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World,My name is LiuRui."
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮1"
android:onClick="onMyButtonClick"
android:id="@+id/button" android:layout_gravity="center_horizontal"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮2"
android:onClick="onMyButton2Click"
android:id="@+id/button2" android:layout_gravity="center_horizontal"/>
</LinearLayout>
5、values——>Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">myapp</string>
<string name="hello">Hello World!My name is LiuRui.</string>
</resources>
6、gen——>R.java
/*___Generated_by_IDEA___*/
package com.example.myapp;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
}
7、运行
Run——>Run‘myapp’


Intellij IDEA开发第一个Android应用的更多相关文章
- Intellij IDEA开发第一个android应用教程
用惯eclipse的同学们可以试试通过Intellij IDEA来开发一个android应用.下面是具体的教程. 首先:下载Intellij IDEA.最新版本是12.官方提供两个版本.一个是Comm ...
- 在开发第一个Android应用之前需要知道的5件事:
你能否详细讲述一下,在开发Android应用过程中每一阶段要用到的技能和编程语言? 建立一个Android应用程序可以归结为两个主要技能/语言:Java和Android系统.Java是Android的 ...
- java Android SDK安装与环境变量配置以及开发第一个Android程序
JAVA的安装与环境变量的配置 1.先下载JAVA,并且安装. 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u3 ...
- 跟我学android-使用Eclipse开发第一个Android应用(三)
打开Eclipse,选择 File—New –Android Application Project Application Name 就是我们的 应用名称,也是我们在手机应用程序列表里看到的名称. ...
- VS2015下的Android开发系列02——用VS开发第一个Android APP
配置Android模拟器 这算是第一篇漏下说的,配置好VS的各参数,新建Android项目后,会发现菜单下的工具栏会多出Android相关的工具栏,红色圈出的就是AVD. 打开AVD后可以从模版处选一 ...
- 使用Kotlin开发第一个Android应用
直奔主题 第一步:为AndroidStudio安装Kotlin插件 在线安装步骤:File—>Settings—>Plugins—>Install JetBrains plugin… ...
- android开发------第一个android程序
好吧,现在我们就一起来写第一个android程序,看它带给了我们什么.sdk的使用和虚拟机的创建我就不说了.项目创建过程先略过,不太重要. 那第一个程序我们能学到什么知识呢?一起看吧.^-^ 在IDE ...
- 开始第一个Android应用程序
Android应用程序建立在应用程序框架之上,所以Android编程就是面向应用程序框架API编程---与编写普通的Java SE没有太大区别,只是增加了一些API. 1.使用eclipse开发第一个 ...
- 使用 IntelliJ IDEA 开发 Android 应用程序时配置 Allatori 进行代码混淆
IntelliJ IDEA 提供了非常强大的 Android 开发支持,就连 Google 官方推荐的 Android Studio 其实也是 IntelliJ IDEA 的一个 Android 开发 ...
随机推荐
- php mysql_insert_id()
mysql_insert_id mysql_insert_id()返回给定的 link_identifier中上一步 INSERT 查询中产生的 AUTO_INCREMENT 的 ID 号.如果没有指 ...
- 截取linux文件存储路径方法
1.截取linux文件存储路径方法 package com.tydic.eshop.action.freemarker; public class dddd { public static void ...
- javacc jjtree 写法 以及 jj写法 基本语法 以及应用
/***********************************************************/>我使用的测试jjt,jj文件来自于javacc5.0版本>dir ...
- 51nod 1117 聪明的木匠 (贪心)
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1117 跟挑战程序书上例题一样,将要切割的n断木板,分别对应二叉树树的叶子 ...
- ZOJ Problem Set - 3804 YY's Minions
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5336 比较简单的模拟题,题意也很好理解. #include <iostr ...
- HDU 1244 Max Sum Plus Plus Plus
虽然这道题看起来和 HDU 1024 Max Sum Plus Plus 看起来很像,可是感觉这道题比1024要简单一些 前面WA了几次,因为我开始把dp[22][maxn]写成dp[maxn][2 ...
- 事件对象event和计时器
事件对象:event 属性: srcElement事件源对象 keyCode 键盘按键Ascii码 window方法: 定时器: 1)setTimeout();//n毫秒后执行一次 2)setInte ...
- php字符串与正则表达式试题 Zend权威认证试题讲解
字符串是PHP的“瑞士军刀”——作为一种Web开发语言,PHP最常打交道的就是字符串.因此对于开发者来说,处理字符串是一项非常基础的技能.幸运的是,由于PHP开发团队的努力,PHP对字符串的处理相当易 ...
- HDU1495 非常可乐
解题思路:简单的宽搜,见代码: #include<cstdio> #include<cstring> #include<algorithm> #include< ...
- 【英语】Bingo口语笔记(77) - 临时改变计划的表达