`
shinfocom
  • 浏览: 1189806 次
文章分类
社区版块
存档分类
最新评论

DroisDraw教程(一)

 
阅读更多

DroidDraw Tutorial

Step Zero

This tutorial will give you a brief introduction to developing a GUI application on Android using the DroidDraw user interface designer. This tutorial assumes that you have downloaded and installed the Android SDK. This tutorial also assumes that you are reasonably familiar with concepts in GUI programming and the Java programming language.

Step One

Go to the DroidDraw UI Designer.

Step Two

Set the root layout to RelativeLayout

Step Three

Select the "Layouts" tab.

Step Four

Drag and drop a LinearLayout object from the Layouts panel into the top-center of the screen

Step Five

Select the LinearLayout object and click on the properties tab to begin editing the layout properties. Change the width to "200px" and the height to "130px"

Press "Apply" to apply your changes.

Step Six

Go to the "Widgets" tab.

Step Seven

Drag and drop two TextView objects and two EditText objects into the LinearLayout so that they alternate.

Step Eight

Drag and drop a RadioGroup object into the LinearLayout. Drag and drop two RadioButton objects into the RadioGroup.

Step Nine

Drag and drop a Button object into the root RelativeLayout below the LinearLayout object. It should align with the right edge of the LinearLayout.

Step Ten

Edit the properties of each TextView object. Make text for the upper one read "Dollars" and make its style "bold". Make the lower one read: "Euros" and make its style bold also.

Step Eleven

Edit the properties of the upper EditText as follows:
  • Change the id to read: "@+id/dollars"
  • Change the text to be empty
  • Change the width to be "100px".

Step Eleven and a half

Repeat step eleven with the second EditText under the "Euros" TextView, but make the id be "@+id/euros"

Step Twelve

Edit the first RadioButton so that its text reads: "Dollars to Euros" and its id is "@+id/dtoe".
Edit the second RadioButton so that its text reads: "Euros to Dollars" and its id is "@+id/etod".

Important Note:
You must get the ids exactly correct, because this is how you will look up the widgets in source code.

Step Thirteen

Edit the Button so that its text reads: "Convert" and its id is "@+id/convert".

The final GUI should look like:

Step Fourteen

Press the "Generate" button to generate the layout XML. It will look something like this

Step Fifteen

In Eclipse create a new android project. Cut and paste the XML from DroidDraw to replace the contents of res/layout/main.xml.

At this point you should be able to run your GUI in Android. It should look something like this:

Step Sixteen

The last step is to actually code the currency conversion. There's not much to it, you can look up your GUI elements with:
this.findViewById(R.id.<id>).

Here is the complete code for the CurrencyConverter activity:

Step Seventeen

Well, that's it. I hope you enjoyed the tutorial. Comments and Questions to brendan.d.burns on gmail!
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;

public class CurrencyConverter extends Activity implements OnClickListener {
	TextView dollars;
	TextView euros;
    RadioButton dtoe;
    RadioButton etod;
	Button convert;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        
        dollars = (TextView)this.findViewById(R.id.dollars);
        euros = (TextView)this.findViewById(R.id.euros);
        
        dtoe = (RadioButton)this.findViewById(R.id.dtoe);
        dtoe.setChecked(true);
        etod = (RadioButton)this.findViewById(R.id.etod);
        
        convert = (Button)this.findViewById(R.id.convert);
        convert.setOnClickListener(this);
    }
    
	public void onClick(View v) {
		if (dtoe.isChecked()) {
			convertDollarsToEuros();
		}
		if (etod.isChecked()) {
			convertEurosToDollars();
		}
	}
	
	protected void convertDollarsToEuros() {
		double val = Double.parseDouble(dollars.getText().toString());
		// in a real app, we'd get this off the 'net
		euros.setText(Double.toString(val*0.67));
	}
	
	protected void convertEurosToDollars() {
		double val = Double.parseDouble(euros.getText().toString());
		// in a real app, we'd get this off the 'net
		dollars.setText(Double.toString(val/0.67));
	}
}
分享到:
评论

相关推荐

    实现坐标转换程序(C#桌面窗体)

    需手动输入坐标,实现ECEF空间直角坐标系等四种坐标之间相互转换。 具体代码流程可见主页文章。 通过下拉框,自由选择输入输出坐标系后,在左侧文本框手动输入一组或多组坐标,可以实现ECEF空间直角坐标系,ECEF球面坐标系,ECEF椭球坐标系(大地坐标系),站心坐标系四个坐标系统之间的自由转换,共12种转换方式。然后将转换后的坐标结果输入到右边文本框。 适用于GNSS相关课程的编程作业,测绘、地信等专业实践。 ------------------------------------------------------------------------------------------------------------------------- 该代码可能存在部分不足与漏洞。实际运行时没有发生过错误。

    基于matlab实现直角坐标系下的牛顿拉夫逊潮流计算MATLAB程序.rar

    基于matlab实现直角坐标系下的牛顿拉夫逊潮流计算MATLAB程序.rar

    基于matlab实现麦克风阵列SRP-PHAT算法的二级空间快速声源定位,含模拟环境 .rar

    基于matlab实现麦克风阵列SRP-PHAT算法的二级空间快速声源定位,含模拟环境。.rar

    node-v10.16.0-linux-arm64.tar.xz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    dephi+sqlserver2000题库与试卷生成系统.zip

    dephi+sqlserver2000题库与试卷生成系统.zip

    node-v10.24.0-darwin-x64.tar.xz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    ASP+ACCESS网页设计辅导系统(源代码+设计说明书).zip

    ASP+ACCESS网页设计辅导系统(源代码+设计说明书).zip

    中考实验视频.zip

    中考实验视频.zip

    基于VB+access实现的学生成绩管理系统(开题报告+答辩PPT+论文+系统).zip

    基于VB+access实现的学生成绩管理系统(开题报告+答辩PPT+论文+系统) 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。

    基于matlab实现模拟退火程序 f(x,y) = 5sin(xy) + x^2 + y^2的最小值

    基于matlab实现模拟退火程序。f(x,y) = 5sin(xy) + x^2 + y^2的最小值,对理解模拟退火算法是一个很好的程序示例.rar

    node-v5.4.1.tar.xz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    ASP+access网上人才信息管理系统毕业设计(源代码+设计说明书).zip

    ASP+access网上人才信息管理系统毕业设计(源代码+设计说明书).zip

    node-v10.22.1-linux-ppc64le.tar.xz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    node-v12.16.3-linux-armv7l.tar.xz

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    CASS工艺参数设计计算表.xls

    污水处理计算书

    ASP+ACCESS文学网站建设设计(源代码+设计说明书+系统).zip

    ASP+ACCESS文学网站建设设计(源代码+设计说明书+系统).zip

    http代理服务器的实现(程序).zip

    http代理服务器的实现(程序).zip

    node-v6.14.4-x64.msi

    Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。

    JSP教学管理系统设计(源代码+设计说明书).zip

    JSP教学管理系统设计(源代码+设计说明书).zip

    2024年木纹砖行业分析报告.pptx

    行业报告

Global site tag (gtag.js) - Google Analytics