onActivityResult the use-value

Sometimes the groups have added new people always like to ask some questions sometimes do not answer the past because of the frequency response more

Does not answer it against people who let their contact with the enthusiasm of the early strength in order to save or do simple things to it as a guide articles

More activity by value between the fact onActivityResult, then do not forget there is an action of the problem is in the main xml add your own action in order to facilitate identification, do not forget the last time activity finansh.

public class Wizard extends Activity {

    private TextView step1result, step2result, step3result;

    public static final String INTENT_STEP1 = "com.novoda.STEP1";
    public static final String INTENT_STEP2 = "com.novoda.STEP2";
    public static final String INTENT_STEP3 = "com.novoda.STEP3";

    private static final int STEP1 = 1;
    private static final int STEP2 = 2;
    private static final int STEP3 = 3;

    public void onCreate(Bundle savedInstanceState) {

        this.step1result = (TextView)findViewById(R.id.step1result);
        this.step2result = (TextView)findViewById(R.id.step2result);
        this.step3result = (TextView)findViewById(R.id.step3result);  

        startActivityForResult(new Intent(Wizard.INTENT_STEP1), STEP1);

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
            case STEP1:
                startActivityForResult(new Intent(Wizard.INTENT_STEP2), STEP2);
            case STEP2:
                startActivityForResult(new Intent(Wizard.INTENT_STEP3), STEP3);
            case STEP3:
public class Step1 extends Activity {

    public void onCreate(Bundle savedInstanceState) {

        Button nextStep = (Button)findViewById(R.id.goto2);
        nextStep.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent it = new Intent();
                it.putExtra("STEP1RESULT", ((EditText)findViewById(R.id.step1value)).getText()
                setResult(Activity.RESULT_OK, it);

The back are the same the step2 step3

Then there is the main xml

<application android:icon="@drawable/icon" android:label="@string/app_name">
                <activity android:name=".Wizard" android:label="@string/app_name">
                                <action android:name="android.intent.action.MAIN" />
                                <category android:name="android.intent.category.LAUNCHER" />

                <activity android:name=".Step1" android:label="Step1">
                                <action android:name="com.novoda.STEP1" />
                                <category android:name="android.intent.category.DEFAULT" />

                <activity android:name=".Step2" android:label="Step2">
                                <action android:name="com.novoda.STEP2" />
                                <category android:name="android.intent.category.DEFAULT" />

                <activity android:name=".Step3" android:label="Step3">
                                <action android:name="com.novoda.STEP3" />
                                <category android:name="android.intent.category.DEFAULT" />
        <uses-sdk android:minSdkVersion="7" />
分类:Mobile 时间:2010-04-04 人气:256
blog comments powered by Disqus


  • public void testStatementAddBatch () public void testConnCommit () 2011-09-01

    public void testStatementAddBatch() { Connection conn = null; Statement stmt = null; try { conn = getDBConnectionMsSqlBySuperAdmin(); stmt = conn.createStatement(); for(int i = 0; i < 100; i++) { String sql = " sql " + i; stmt.addBatch(sql);

  • Android四大组件之Activity 2012-04-26

    Activity定义 Activity是一种提供了屏幕并能让用户做一些交互的应用组件,就像拨号,拍照,发送电子邮件或者浏览地图,每一个activity被给与了用于绘制用户界面的窗口,一般窗口都是充满屏幕的,但可能比屏幕小一点并且浮在其他窗口之上. 一个应用通常由多个相互紧密联系的Activies组成,典型的一个activity在应用中被指定成"主"activity,用户第一次运行应用所显现的.为了能执行不同的行为每个activity可以运行另一个activity.每次一个新的Activ

  • asp.net application life cycle 2013-01-17

    Introduction In this article, we will try to understand what the different events are which take place right from the time the user sends a request, until the time the request is rendered on the browser. So we will first try to understand the two bro

  • android之Fragment(官网资料翻译) 2013-05-26

    Fragment要点 Fragment作为Activity界面的一部分组成出现 可以在一个Activity中同时出现多个Fragment,并且,一个Fragment亦可在多个Activity中使用. 在Activity运行过程中,可以添加.移除或者替换Fragment(add().remove().replace()) Fragment可以响应自己的输入事件,并且有自己的生命周期,当然,它们的生命周期直接被其所属的宿主activity的生命周期影响. 设计哲学 Android在3.0中引入了fr

  • Fragment 2014-04-22

    Fragment要点 Fragment作为Activity界面的一部分组成出现 可以在一个Activity中同时出现多个Fragment,并且,一个Fragment亦可在多个Activity中使用. 在Activity运行过程中,可以添加.移除或者替换Fragment(add().remove().replace()) Fragment可以响应自己的输入事件,并且有自己的生命周期,当然,它们的生命周期直接被其所属的宿主activity的生命周期影响. 设计哲学 Android在3.0中引入了fr

  • struts1 garbage problem-solving 2010-04-27

    Recently, the use of struts 1.1, found that annoying issue of the Chinese garbled in the form of the transfer process and the storage time to appear. On my way to find the network listed as follows: (Tomcat 5.0.28 + struts 1.1 + hibernate 2.1 + sqlse

  • Tomcat source code --- Request Processing 2 2010-03-24

    1, after the above article (JIoEndpoint $ Worker # run) the implementation of the socket to the tomcat successfully in the implementation of the coyote pack org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler # process (Socket socket) p

  • [Tomcat Source Series] Structure of 3) request processing control structure 2010-03-28

    First, the basis of the request processing control structure and life of structures similar to the request processing is a two-tier structure 1.Valve: Valve is the smallest processing unit, we look at the definition of Valve A Valve is a request proc

  • HttpClient and Tomcat garbled 2010-04-19

    These days are entangled Java Web Development in Chinese encoding. In fact, many Java Web developers have been coding in Chinese "torture" However, there are a lot of discussion on the network. Before I read this blog post, after reading feeling

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 闽ICP备15018612号

processed in 2.014 (s). 10 q(s)