android word编程,Android HelloWord编写方式介绍

Android HelloWord程序的实现可以通过这里介绍的代码编写方式实现。希望初学者们可以以此为参考对象,对这一应用方式有所了解。

相信学过编程的人员都对各种语言的helloword程序的编写方式记忆犹新吧。在这里我们就为大家详细介绍一下有关Android HelloWord的编写方式,方便大家对这一操作系统编写方式的理解。

先说说整个程序要做哪些内容吧,简单helloword 通过一个按钮点击在另一个acitvity出现文本Hello xiaoshengDAI

说下Android HelloWord做的步骤吧:

1.首先新建项目,我这边主要是测试Layout所以项目名就叫这个了。

2.我们要显示一个按钮,难后点击这个按钮就转到其他activity显示Hello xiaoshengDAI,新建类Layout主要来显示第一个activity即button,

1).在main.xml文件中进行配置

Java代码<?xmlversion ="1.0"encoding="utf-8"?>

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="来点我吧"/>

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="来点我吧"/>

2).设置监听和跳转actiovity

Java代码

package com.layout;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

public class Layout extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

OnClickListenerlistener1=null;

Buttonbotton1=null;

listener1=newOnClickListener(){

public void onClick(View v) {

Intentintent0=newIntent(Layout.this,

ActivityFrameLayout.class);

setTitle("FrameLayout");

startActivity(intent0);

}

};

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

botton1= (Button) findViewById(R.id.button1);

botton1.setOnClickListener(listener1);

}

}

package com.layout;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

public class Layout extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

OnClickListenerlistener1=null;

Buttonbotton1=null;

listener1=newOnClickListener(){

public void onClick(View v) {

Intentintent0=newIntent(Layout.this,

ActivityFrameLayout.class);

setTitle("FrameLayout");

startActivity(intent0);

}

};

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

botton1= (Button) findViewById(R.id.button1);

botton1.setOnClickListener(listener1);

}

}

3.在Android HelloWord编写中,新建activityFrameLayout类和activityFrameLayout.xml文件

Java代码

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="Hello xiaoshengDAI"

/>

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="Hello xiaoshengDAI"

/>

Java代码

package com.layout;

import android.app.Activity;

import android.os.Bundle;

public class ActivityFrameLayout extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setTitle("哈哈");

setContentView(R.layout.activityframelayout);

}

}

package com.layout;

import android.app.Activity;

import android.os.Bundle;

public class ActivityFrameLayout extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setTitle("哈哈");

setContentView(R.layout.activityframelayout);

}

}

4.对AndroidManifest.xml进行配置,将新建Activity配置文件加进来

Android HelloWord的Java代码

package="com.layout"

android:versionCode="1"

android:versionName="1.0">

android:label="@string/app_name">

package="com.layout"

android:versionCode="1"

android:versionName="1.0">

android:label="@string/app_name">

5.Android HelloWord可以运行了,嘿嘿

【责任编辑:曹凯 TEL:(010)68476606】

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值