《android 4高级编程》--第2章 开始入手 "又是一个hello world"
来源:互联网 发布:kafka java 编辑:程序博客网 时间:2024/05/21 10:52
熟悉用eclipse开发应用,在我之前的写的 eclipse 搭建android环境补充有说明。
其实开始比较简单无非就是了解eclipse怎么安装利用ADT插件迅速搭建一个工程,然后运行调试显示结果。
下面是我搭建环境写的第一个应用"hello world"-------------->什么东西开始都是一个hello world,以后有机会开个咖啡店,名字就是“hello world".
代码如下:
package com.paad.helloworld;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView myTextViem = (TextView)findViewById(R.id.myTextViem);
myTextViem.setText(getString(R.string.hello_world));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/myTextViem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">PA4AD_CH02_Hello_world</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
</resources>
最主要的布局文件:
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.paad.helloworld"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.paad.helloworld.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
- 《android 4高级编程》--第2章 开始入手 "又是一个hello world"
- 第2章、hello,world!
- 又是一个开始
- 又是一个开始?
- 又是一个开始
- 第2章、第一个“Hello,world!”之Android App
- 第3章 Spring Boot快速开始Hello World
- 第一天:从"Hello World"开始
- 第一篇博客从hello world开始
- 又是一个新开始
- 又是一个新开始
- Android 开发之旅:深入分析布局文件&又是“Hello World!”
- Android 开发之旅:深入分析布局文件&又是“Hello World!”
- Android 开发之旅:深入分析布局文件&又是“Hello World!”
- Android 开发之旅:深入分析布局文件&又是“Hello World!”
- spring step 2 : 又见hello world!
- 一个结束,又是一个开始
- 开始使用Android Sutdio(三)创建一个Hello World程序
- js综合应用:表格的四则运算
- hive Exceeded MAX_FAILED_UNIQUE_FETCHES; bailing-out.
- 绕过权限检查新增数据
- Tomcat 6 server
- 格式转换
- 《android 4高级编程》--第2章 开始入手 "又是一个hello world"
- onInterceptTouchEvent和onTouchEvent调用时序
- hibernate以及实体配置文件最简形式
- spring mvc 无法使用EntityManage和注入问题
- jasperreport实现Html、Pdf、Rtf、 Excel、Xml报表导出
- hibernate笔记(一)
- hotplug
- MySQL远程访问权限,允许远程连接的开启及局域网访问慢解决办法
- Adobe CS6和CS6.5官方简体中文英文原版版全系列迅雷下载地址