1、AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fish.helloworld"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Receive"
android:label="@string/title_activity_receive" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Send"
android:label="@string/title_activity_send" >
</activity>
</application> </manifest>

2、Receive

package com.fish.helloworld;

import com.fish.helloworld.Forwarding.backButton_OnClickListener;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView; public class Receive extends Activity { private backButton_OnClickListener backButtonListener = new backButton_OnClickListener();
private TextView m_TextView; static final private int GET_CODE = 0; class backButton_OnClickListener implements OnClickListener{
public void onClick(View v){
Intent intent = new Intent(Receive.this, Send.class);
startActivityForResult(intent, GET_CODE); }
} @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.receive_result); final Button backButton = (Button)findViewById(R.id.button1);
backButton.setOnClickListener(backButtonListener); m_TextView = (TextView)findViewById(R.id.textView1);
} @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if(requestCode == GET_CODE){
String text = "";
if(resultCode == RESULT_CANCELED){ text = "Corkey";
}else{ text = "Violet";
}
m_TextView.setText(text);
} } }

3、Send

package com.fish.helloworld;

import com.fish.helloworld.Receive.backButton_OnClickListener;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button; public class Send extends Activity { private backButton_OnClickListener backButtonListener = new backButton_OnClickListener();
private backButton_OnClickListener2 backButtonListener2 = new backButton_OnClickListener2(); class backButton_OnClickListener implements OnClickListener{
public void onClick(View v){
setResult(RESULT_OK, (new Intent().setAction("Corkey!")));
finish();
}
}
class backButton_OnClickListener2 implements OnClickListener{
public void onClick(View v){
setResult(RESULT_CANCELED, (new Intent().setAction("Violet!")));
finish();
}
} @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.send_result); final Button backButton = (Button)findViewById(R.id.button1);
backButton.setOnClickListener(backButtonListener); final Button backButton2 = (Button)findViewById(R.id.button2);
backButton2.setOnClickListener(backButtonListener2);
} }

Android带返回值的窗口跳转的更多相关文章

  1. 064 01 Android 零基础入门 01 Java基础语法 08 Java方法 02 无参带返回值方法

    064 01 Android 零基础入门 01 Java基础语法 08 Java方法 02 无参带返回值方法 本文知识点:无参带返回值方法 说明:因为时间紧张,本人写博客过程中只是对知识点的关键步骤进 ...

  2. 慕课网-Java入门第一季-7-3 Java 中无参带返回值方法的使用

    来源:http://www.imooc.com/code/1579 如果方法不包含参数,但有返回值,我们称为无参带返回值的方法. 例如:下面的代码,定义了一个方法名为 calSum ,无参数,但返回值 ...

  3. Java 中带参带返回值方法的使用

    如果方法既包含参数,又带有返回值,我们称为带参带返回值的方法. 例如:下面的代码,定义了一个 show 方法,带有一个参数 name ,方法执行后返回一个 String 类型的结果 调用带参带返回值的 ...

  4. Java 中无参带返回值方法的使用

    如果方法不包含参数,但有返回值,我们称为无参带返回值的方法. 例如:下面的代码,定义了一个方法名为 calSum ,无参数,但返回值为 int 类型的方法,执行的操作为计算两数之和,并返回结果 在 c ...

  5. EF5中 执行 sql语句使用Database.ExecuteSqlCommand 返回影响的行数 ; EF5执行sql查询语句 Database.SqlQuery 带返回值

    一: 执行sql语句,返回受影响的行数 在mysql里面,如果没有影响,那么返回行数为  -1 ,sqlserver 里面  还没有测试过 using (var ctx = new MyDbConte ...

  6. 测试 多线程 实现 callable 带返回值

    package threadTest; import java.util.ArrayList; import java.util.Date; import java.util.concurrent.C ...

  7. Mysql带返回值与不带返回值的2种存储过程

    过程1:带返回值: 1 drop procedure if exists proc_addNum; 2 create procedure proc_addNum (in x int,in y int, ...

  8. c++中带返回值函数没写return能通过编译但运行时会出现奇怪问题

    c++中带返回值函数没写return能通过编译但运行时会出现奇怪问题 例如: string myFunc(){ theLogics(); } 发现调用: myFunc(); 崩溃. 但调用: cout ...

  9. 13 继续C#中的方法,带返回值的方法介绍

    在这一个练习中,我们要使用带返回值的方法.如果一个方法带返回值,那么它的形式是这样的. 定义一个带返回值的C#方法 static 返回类型 方法名字 (参数类型 参数1的名字,参数类型 参数2的名字) ...

随机推荐

  1. spring外部化配置

    例如 <bean id="dataSource" class="....." p:username="aa" p:password=& ...

  2. 如何开启ubuntu的SSH服务(不要和openssl搞混淆了)

    ubuntu默认并没有安装ssh服务,如果通过ssh链接ubuntu,需要自己手动安装ssh-server,然而SSH分客户端openssh-client和服务端openssh-server,open ...

  3. Number of Islands

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...

  4. iOS学习之UIActionSheet的使用

    UIActionSheet是在iOS弹出的选择按钮项,可以添加多项,并为每项添加点击事件. 为了快速完成这例子,我们打开Xcode 4.3.2, 先建立一个single view applicatio ...

  5. ruby关于flip-flop理解上一个注意点

    (..).each do |x| puts x ) .. (x == ) end 上面的flip-flop的用法,你可以理解成 将 大于等于5和小于等于10的数字打印出来,也就是理解成  puts x ...

  6. nginx 均衡负载配置

    nginx详细配置介绍: 参考资料:http://blog.csdn.net/xmtblog/article/details/42295181 配置实例: // nginx服务器虚拟为代理服务器和we ...

  7. codeblocks调试快捷键说明

    使用codeblocks避免不了快捷键: 在调试程序的时候: 首先在view->toolbar->debugger调出来:快捷方式可以自己看 RUN to Cursor  :F4 单步调试 ...

  8. 转载cocos2dx的各种动作用法

    以下内容来源于:http://www.cnblogs.com/linux-ios/archive/2013/04/06/3001946.html 转载时请保留以上链接. bool HelloWorld ...

  9. maven配置开发

    1.项目中使用Log4j对其日志进行配置管理,采取的方式一种是通过properties文件设置,另一种方式就是通过设置xml文件的配置. 使用场景: 编程模型:log.err();log.debug( ...

  10. 常见的MIME类型

    超文本标记语言文本 .htm,.html text/html 普通文本 .txt text/plain GIF图形 .gif image/gif JPEG图形 .ipeg,.jpg image/jpe ...