先说说整个程序要做哪些内容吧,简单helloword 通过一个按钮点击在另一个acitvity出现文本Hello xiaoshengDAI
具体包结构如下图
说下做的步骤吧:
1.首先新建项目,我这边主要是测试Layout所以项目名就叫这个了。
2.我们要显示一个按钮,难后点击这个按钮就转到其他activity显示Hello xiaoshengDAI,新建类Layout主要来显示第一个activity即button,
1).在main.xml文件中进行配置
<?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">
<Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="来点我吧"/>
</LinearLayout>
2).设置监听和跳转actiovity
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) {
OnClickListener listener1 = null;
Button botton1 = null;
listener1 = new OnClickListener(){
public void onClick(View v) {
Intent intent0 = new Intent(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.新建activityFrameLayout类和activityFrameLayout.xml文件
<?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="Hello xiaoshengDAI"
/>
</LinearLayout>
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配置文件加进来
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.layout"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Layout"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ActivityFrameLayout" android:label="activityFrameLayout">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>
5.可以运行了,嘿嘿
- 大小: 26.1 KB
分享到:
相关推荐
android helloword
arcgis forandroid helloword 。 第一个程序!
arcgis for android helloword demo 一个非常简单的arcgis demo 本人测试成功上传的 异常花费了本人一上午时间
android入门示例,讲解了从strings.xml配置文件中读取变量显示在界面上,在界面上显示helloworld以及代码入口的基础
Android HelloWord code 初学者可以跑一下
第一个Android程序 HelloWord.zip
Android基础——Android Studio2.1配置NDK运行HelloWord
hello world视频教程,希望能够学习者提供帮助,实现对Android基础知识的掌握与理解,为后续学习做好铺垫,实现Android知识的灵活运用
android系统helloword。初学者使用。
android 平台下的helloword源代码,非常适合对于android有兴趣的开发人员使用
Android环境搭配及简单HelloWord 做为入门者不得不看的教程
helloword
Android环境搭配及简单HelloWord.pdf
自己搭建的android 开发环境 做的一个模拟器
Android环境搭配及简单HelloWord.pdf
android jni例程,主要是环境的配置,在android studio2.3.3调试通过
android studio下 ffmepg环境搭建的代码
android调用第三方库,博客中helloword实例,请去看博客