`
VerRan
  • 浏览: 456929 次
  • 性别: Icon_minigender_1
  • 来自: 陕西.西安
社区版块
存档分类
最新评论

Android 学习之一

    博客分类:
  • JAVA
阅读更多

   去年4月份开始关注Android 当时由于时间问题只是做了简单的学习,并没有做下笔记。家里办了e9正好送了个ZTE的N600,让我又有了重新学习anDroid的想法,学习历程留下痕迹便于以后翻阅。

 

1. 环境搭建

    这个网上有很多例子,再次不再赘述。

2. 启程Hello Android(做一个 点击按钮 然后弹出一个警告框的示例)

    先看核心代码吧

   

package oms.hello;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class HelloAndroid extends Activity {//一个activity 可以理解为一个页面

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);//设置页面显示的信息
		Button button = (Button) findViewById(R.id.button);//根据ID查找要使用的组建
		button.setOnClickListener(new OnClickListener() {//设置按钮点击时间
			public void onClick(View v) {
				openDialog();//出发按钮点击事件时执行的方法
			}
		});
	}

	private void openDialog() {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);//创建警告框对象
		builder.setTitle("Hello");
		builder.setMessage("Hello World \n");
		builder.setNegativeButton("OK", null);
		builder.show();
	}

}

 

3. 组建定义

<?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="@string/hello" />
	<Button android:id="@+id/button" android:text="@string/click_me"
		android:layout_width="wrap_content" android:layout_height="wrap_content">
	</Button>

	<LinearLayout android:orientation="horizontal"
		android:layout_width="fill_parent" android:layout_height="fill_parent"
		android:layout_weight="1">

		<TextView android:text="red" android:gravity="center_horizontal"
			android:background="#aa0000" android:layout_width="wrap_content"
			android:layout_height="fill_parent" android:layout_weight="1" />

		<TextView android:text="green" android:gravity="center_horizontal"
			android:background="#00aa00" android:layout_width="wrap_content"
			android:layout_height="fill_parent" android:layout_weight="1" />

		<TextView android:text="blue" android:gravity="center_horizontal"
			android:background="#0000aa" android:layout_width="wrap_content"
			android:layout_height="fill_parent" android:layout_weight="1" />

		<TextView android:text="yellow" android:gravity="center_horizontal"
			android:background="#aaaa00" android:layout_width="wrap_content"
			android:layout_height="fill_parent" android:layout_weight="1" />

	</LinearLayout>

	<LinearLayout android:orientation="vertical"
		android:layout_width="fill_parent" android:layout_height="fill_parent"
		android:layout_weight="1">

		<TextView android:text="row one" android:textSize="15pt"
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_weight="1" />

		<TextView android:text="row two" android:textSize="15pt"
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_weight="1" />

		<TextView android:text="row three" android:textSize="15pt"
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_weight="1" />

		<TextView android:text="row four" android:textSize="15pt"
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_weight="1" />

	</LinearLayout>
</LinearLayout> 

 

4.  公共资源信息定义

<?xml version="1.0" encoding="utf-8"?>
<resources>
	<string name="hello">Hello World, helloworld!</string>
	<string name="app_name">helloworld</string>
	<string name="click_me">click_me</string>
</resources> 

 

5. 组建

/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package oms.hello;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
    }
    public static final class id {
        public static final int button=0x7f050000;
    }
    public static final class layout {
        public static final int main=0x7f030000;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int click_me=0x7f040002;
        public static final int hello=0x7f040000;
    }
}

 

分享到:
评论

相关推荐

    第一行代码 android学习笔记 完整版

    "Android学习笔记" Android学习笔记是Android开发者的必读书籍,书中涵盖了Android系统架构、Activity、Intent、资源管理等多方面的知识。本笔记对应的学习资源《第一行代码》是Android开发者的入门必读书籍,书中...

    Android学习资源网址

    在当今移动互联网时代,Android操作系统作为全球最广泛使用的移动设备平台之一,其重要性不言而喻。对于开发者而言,掌握Android开发技能不仅能够提升个人职业竞争力,还能够为用户提供更加丰富、便捷的应用体验。...

    Android学习之路

    Android 学习之路 Android 学习之路是 Android 开发者的必经之路,对于初学者来说,了解 Android 开发的分类非常重要。Android 开发可以分为四大类:Android 客户端应用程序、Android 通用类程序、Android 游戏...

    Android学习体系.pdf

    Android学习体系涵盖了从基础知识到高级应用的全方位课程内容,注重理论与实践相结合,旨在培养具备全面Android开发技能的专业人才。以下是根据提供的文件内容详细解读的知识点: 一、Android未来发展趋势: ...

    Android学习之路——4.Activity简介

    这篇博客"Android学习之路——4.Activity简介"很可能会详细解释Activity的基本概念、生命周期以及如何在实践中使用它。 Activity作为Android应用程序的一个窗口,它可以显示用户界面,并响应用户的交互。每个...

    android学习代码demo

    【Android学习代码Demo】 在移动应用开发领域,Android是最受欢迎的操作系统之一,广泛应用于智能手机和平板电脑。这个“Android学习代码demo”集合提供了一个实践学习Android开发的良好平台,特别是对于初学者或者...

    Android学习之Broadcast练习_dlc

    本实践项目"Android学习之Broadcast练习_dlc"旨在帮助开发者深入理解和熟练掌握Broadcast的相关知识。 首先,我们要了解Broadcast的基本概念。Broadcast分为系统广播和自定义广播。系统广播是由系统发出的,例如...

    android学习小例子

    这里我们关注的是"android学习小例子",它涵盖了Android应用开发中的关键元素:Activity、Service、Fragment以及Dialog。这些组件是构建Android应用程序的基础,理解并熟练运用它们对于成为一名合格的Android开发者...

    Android学习路线

    标题中提到的是“Android学习路线”,这指向了Android移动应用开发的系统性学习方案。由于Android是一个极为复杂的移动操作系统,其应用开发过程涵盖了广泛的知识点和技术栈,因此学习路线将帮助开发者梳理这些知识...

    android 学习书籍大全

    在Android学习的道路上,拥有一套全面且深入的书籍资源是非常重要的。"android 学习书籍大全"这个压缩包很可能包含了从入门到进阶的各种Android开发教程,虽然可能有些资料的时间较早,但Android的基本原理和技术...

    Android学习之手机通讯录

    本项目“Android学习之手机通讯录”聚焦于使用ContentProvider操作手机内置的通讯录,包括查询、添加和删除联系人。尽管删除功能存在不足,但这个练习仍能帮助我们深入理解ContentProvider的工作原理。 首先,我们...

    安卓SQLite数据库相关-Android学习之数据存储.rar

    本资源包“安卓SQLite数据库相关-Android学习之数据存储.rar”似乎包含了一些关于在Android中使用SQLite的示例代码和参考资料,虽然未提供全部验证,但可以作为学习和参考的起点。 首先,我们需要理解SQLite在...

    android入门学习资料

    本套学习资料旨在帮助初学者快速掌握Android开发的基本技能,内容涵盖Android开发中文文档以及一系列由eoeAndroid推出的特刊,为您的学习之路提供全面而深入的指导。 首先,我们关注的是《Android开发指南中文版....

    android学习源码

    《Android学习源码详解》 Android,作为全球最受欢迎的移动操作系统之一,对于开发者而言,深入学习其源码显得尤为重要。本资源集包含了Android各个方面的学习例子,共计25章,近200个实例,是Android初学者理想的...

    android 学习资料 pdf ppt

    4. **Android 控件之ImageSwitcher**:ImageSwitcher是Android中的一个控件,用于在两个ImageView之间平滑地切换图片。对应的"MHT"文件可能是对这个控件的深入讲解,包括它的用法、属性、事件处理以及如何实现动画...

    Android开发学习笔记

    在Android开发中,`Button`控件是最常用的用户界面元素之一,用于触发特定的操作或事件。本文档将详细讲解如何创建并自定义一个简单的按钮,并设置点击事件来改变应用的状态。 ##### 创建Button 1. **项目配置** ...

    android学习之控件的显示和隐藏

    ### Android学习之控件的显示与隐藏 在Android应用程序开发中,经常需要通过改变界面元素的可见性来实现动态更新用户界面(UI)的效果。这种需求通常体现在响应用户交互、根据应用状态变化调整UI布局等方面。本文将...

    android学习文档

    首先,"Android入门教程"是开始Android学习之旅的关键。这个教程通常会介绍Android开发环境的搭建,包括安装Android Studio,这是Google官方推荐的集成开发环境(IDE)。在Android Studio中,你可以创建新的项目,...

    android 学习心得

    `Android-Manifest.xml` 文件是每个Android应用的核心配置文件之一,用于向Android系统声明应用的各种组件和权限需求等。其中 `&lt;activity&gt;` 标签用于定义应用程序的一个或多个Activity组件。 - **`android:...

Global site tag (gtag.js) - Google Analytics