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;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.wizard);

        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:
                this.step1result.setText(data.getStringExtra("STEP1RESULT"));
                startActivityForResult(new Intent(Wizard.INTENT_STEP2), STEP2);
                break;
            case STEP2:
                this.step2result.setText(data.getStringExtra("STEP2RESULT"));
                startActivityForResult(new Intent(Wizard.INTENT_STEP3), STEP3);
                break;
            case STEP3:
                this.step3result.setText(data.getStringExtra("STEP3RESULT"));
                break;
        }
    }
}
public class Step1 extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.step1);

        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()
                        .toString());
                setResult(Activity.RESULT_OK, it);
                finish();
            }
        });
    }
}

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">
                        <intent-filter>
                                <action android:name="android.intent.action.MAIN" />
                                <category android:name="android.intent.category.LAUNCHER" />
                        </intent-filter>
                </activity>

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

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

                <activity android:name=".Step3" android:label="Step3">
                        <intent-filter>
                                <action android:name="com.novoda.STEP3" />
                                <category android:name="android.intent.category.DEFAULT" />
                        </intent-filter>
                </activity>
        </application>
        <uses-sdk android:minSdkVersion="7" />
</manifest>
分类:Mobile 时间:2010-04-04 人气:251
分享到:
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);

  • 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

  • dwr request to obtain the server information, etc. 2010-04-25

    In dwr programming should take into account two classes WebContext and WebContextFactory By wc can get request response config context session So also can call wc.getContainer () Returns a Container object IoC container Another way is to completely s

  • Translation How Tomcat Works (Chapter IV) 2010-06-22

    Chapter IV: Tomcat Default Connector Overview Chapter III of the connector to run well, and has completed many outstanding tasks. However, it is designed only as a teaching tool, only the default Tomcat connector for an entry. Chapter III of the conn

  • [How Tomcat Works] Chapter 4, the default Tomcat connector 2010-06-29

    Translator jarfield Blog http://jarfield.javaeye.com Outline HTTP 1.1 new features Persistent connections (Persistent Connections) Chunked encoding (Chunked Encoding) 100 (Continue) status code to use Connector Interface HttpConnector class Create a

  • Java Servlet API documentation for the Second Chinese 2010-08-21

    1, HttpServletRequest Interface Definition of \ public interface HttpServletRequest extends ServletRequest; Servlet to process an format of HTTP request information. Method 1, getAuthType public String getAuthType (); Return to this request authentic

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

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

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.090 (s). 12 q(s)