Demo01:Activity的迁移
来源:互联网 发布:淘宝未按约定发布商品 编辑:程序博客网 时间:2024/06/07 20:57
package com.wuqiong.demo01;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.Toast;public class Activity1 extends Activity {private Button button1;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.first_layout);button1 = (Button) findViewById(R.id.button_1);button1.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {Intent intent = new Intent(Activity1.this, Activity2.class);startActivityForResult(intent, 1);}});}@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {super.onActivityResult(requestCode, resultCode, data);switch(requestCode) {case 1:if(resultCode == RESULT_OK) {String returnedData = data.getStringExtra("data_return");Toast.makeText(Activity1.this, returnedData, Toast.LENGTH_SHORT).show();button1.setText(returnedData);}break;default:}}}
</pre><pre name="code" class="java"><pre name="code" class="java">package com.wuqiong.demo01;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 Activity2 extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.second_layout);Button button2 = (Button) findViewById(R.id.button_2);button2.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {Intent intent = new Intent();intent.putExtra("data_return", "Activity2 to Activity1");setResult(RESULT_OK, intent);finish();}});}@Overridepublic void onBackPressed() {super.onBackPressed();Intent intent = new Intent();intent.putExtra("data_return", "Activity2 to Activity1");setResult(RESULT_OK, intent);finish();}}
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:id="@+id/button_1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Activity1" /></LinearLayout>
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" ><Button android:id="@+id/button_2" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Activity2" /></LinearLayout>
0 0
- Demo01:Activity的迁移
- demo01
- 20Demo01 一个基于HXFlow的Demo
- Programming Scala第4章demo01 scala的类
- ibatis demo01
- ListView控件Demo01
- netty学习demo01
- 不同app下activity间迁移
- Demo01数据类型__整型__浮点型
- Demo01比较运算符__逻辑运算符
- DHCP服务器的迁移
- 程序员的迁移思考
- SVN库的迁移
- WebSpherePortal的迁移
- 表空间的迁移
- 单标域的迁移
- 关于博客的迁移
- Subversion Edge 的迁移
- git学习笔记1-安装git
- 一起talk Vim吧(第十二回:Vim逍遥刀法)
- 使用Trados翻译XML文件的三种方法
- hdoj1004遇到的问题总结及源代码
- ERROR: 32-bit Linux Android emulator binaries are DEPRECATED解决办法
- Demo01:Activity的迁移
- JVM实用参数(一)JVM类型以及编译器模式
- 设置好arm-linux-gcc环境变量却提示找不到文件
- JScrollView_PageControl_AutoScroll 阅读心得
- 制作TM技巧汇总
- 黑马程序员----面向对象(理解思想)
- buntu实用命令
- 最大子段和
- Spark入门——1:RDD及编程接口