27.02.2014 Views

Android 开发教程

Android 开发教程

Android 开发教程

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

-----------------------------------<strong>Android</strong> 编 程 基 础<br />

android:layout_alignRight="@+id/widget31"><br />

<br />

<br />

步 骤 十 五<br />

在 Eclipse 中 创 建 一 个 新 的 <strong>Android</strong> 工 程 。 从 DroidDraw 剪 切 该 XML 并 粘 贴 替 换 到 res/layout/main.xml 的 内<br />

容 中 。<br />

到 这 里 你 就 可 以 在 <strong>Android</strong> 中 运 行 你 的 GUI。 它 应 该 像 这 样 :<br />

步 骤 十 六<br />

最 后 一 步 是 实 际 的 代 码 货 币 转 换 。 它 不 多 , 你 可 以 用 一 下 代 码 来 查 找 到 你 的 GUI 元 素 :<br />

this.findViewById(R.id.);<br />

下 面 是 完 整 CurrentConverter Activity 的 代 码 :<br />

package zyf.CurrentConverter;<br />

import android.app.Activity;<br />

import android.os.Bundle;<br />

import android.view.View;<br />

import android.view.View.OnClickListener;<br />

import android.widget.Button;<br />

import android.widget.RadioButton;<br />

import android.widget.TextView;<br />

public class CurrentConverter extends Activity<br />

implements OnClickListener {<br />

TextView dollars;<br />

TextView euros;<br />

RadioButton dtoe;<br />

11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!