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 开发 ...
随机推荐
- logstash_agent.conf 语法注意事项
编写配置文件时要注意语法,如新版本的logstash对参数host变更为hosts,去除了port参数等. [root@localhost logstash]# cat logstash_agent. ...
- 原生javascript-常用的函数
[一]添加监听事件 addHandler:function(node,type,fn){if(node.addEventListener){ node.addEventListener(type,fn ...
- 下载安装和OpenCV匹配的Android开发环境
ok blog Android与OpenCV——重新下载安装和OpenCV匹配的Android开发环境 !!OpenCV4Android开发之旅(一)----OpenCV2.4简介及 app通过Jav ...
- perl install module as non-root user
install to local directory. 1. cpan 初始化,不用local::lib,mannual就行,其他auto2. 修改cpan 配置文件 cpan > o conf ...
- jQuery插件:简易年月日选择器
基于jquery写的选择年月日出生日期的插件 <li> <label class="label"><span class="star&quo ...
- Java动手实验及课后程序
课后作业 一.编写程序,消息框显示计算结果 设计思想:导入Scanner包,使用JOptionPane类来实现消息框的输入和结果的显示. 程序代码: package com; import java. ...
- 理解Java的封装与接口
1.封装,即保留有限的外部接口(interface),隐藏具体实施细节. 2.封装在生活中很常见.比如下面是一个充电电筒: 一个用户即使不看说明书,也可以猜到这个电筒的操作: 开关和充电.这个电筒用一 ...
- 51nod 1049 1049 最大子段和 (dp)
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1049 令 dp[i]表示为以a[i]结尾的最大子段和,则 dp[i]= ...
- Android Studio AVD和SDK Manager灰色不能点击的问题。
之前安装完Android Studio之后,迫不及待的打开,新建项目,发现模板新建之后里面没有文件,并且AVD Manager和SDK Manager 那一排的按钮灰色不能点. 之后查阅资料无果,最后 ...
- 如何在Windows系统中配置Mysql群集(Mysql Cluster)
Mysql群集(Cluster)简介 MySQL群集需要有一组计算机,每台计算机的角色可能是不一样的.MySQL群集中有三种节点:管理节点.数据节点和SQL节点.群集中的某计算机可 能是某一种节点,也 ...