标签:android style blog http color os io for
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带返回值的窗口跳转,布布扣,bubuko.com
标签:android style blog http color os io for
原文地址:http://www.cnblogs.com/sshoub/p/3879569.html