首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android入门 上一步 下一步 封存数据 DEMO

2012-06-27 
android入门 上一步 下一步 保存数据 DEMODEMO 木有注视 吼吼 ~~~ package com.isoftstone.cryimport and

android入门 上一步 下一步 保存数据 DEMO

DEMO 木有注视 吼吼 ~~~ 

package com.isoftstone.cry;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;import android.widget.EditText;public class StartActivityForResult_Next extends Activity{private Button btn ;private EditText username,password ;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.a_intent_01);//get Instancebtn = (Button)findViewById(R.id.ai_button1);username = (EditText)findViewById(R.id.ai_username_ed01);password = (EditText)findViewById(R.id.ai_psd_editText2);btn.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubBundle bundle = new Bundle();bundle.putString("username",username.getText().toString());bundle.putString("password",password.getText().toString());Intent intent = new Intent(StartActivityForResult_Next.this,StartActivityForResult_Next2.class);intent.putExtras(bundle);startActivityForResult(intent, 0);}});}@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data){// TODO Auto-generated method stubBundle bundle = data.getExtras();String _username = bundle.getString("username");String _password = bundle.getString("password");username.setText(_username);password.setText(_password);}}

<?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" >    <TextView        android:id="@+id/ai_textView1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="username" />    <EditText        android:id="@+id/ai_username_ed01"        android:layout_width="match_parent"        android:layout_height="wrap_content">    </EditText>    <TextView        android:id="@+id/ai_textView2"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="password" />    <EditText        android:id="@+id/ai_psd_editText2"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:inputType="textPassword" />    <Button        android:id="@+id/ai_button1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="下一步" /></LinearLayout>

package com.isoftstone.cry;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.widget.Button;public class StartActivityForResult_Next2 extends Activity{private Button btn ;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.a_intent_02);btn = (Button)findViewById(R.id.ai_button02);btn.setOnClickListener(new View.OnClickListener(){@Overridepublic void onClick(View v) {// TODO Auto-generated method stubIntent intent = getIntent();//设置返回结果StartActivityForResult_Next2.this.setResult(0,intent);//结束当前activityStartActivityForResult_Next2.this.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" >    <TextView        android:id="@+id/textView1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Email" />    <EditText        android:id="@+id/ai_ditText01"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:inputType="textEmailAddress" >    </EditText>    <TextView        android:id="@+id/ai_textView02"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="mobile" />    <EditText        android:id="@+id/ai_editText02"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:inputType="phone" />    <Button        android:id="@+id/ai_button02"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="上一步" /></LinearLayout>

热点排行