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 ; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.a_intent_01); //get Instance btn = (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() { @Override public void onClick(View v) { // TODO Auto-generated method stub Bundle 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); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub Bundle 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 ; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.a_intent_02); btn = (Button)findViewById(R.id.ai_button02); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = getIntent(); //设置返回结果 StartActivityForResult_Next2.this.setResult(0,intent); //结束当前activity StartActivityForResult_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>
相关推荐
huha 2020-10-16
xfcyhades 2020-11-20
sgafdsg 2020-11-04
Michael 2020-11-03
fengyeezju 2020-10-14
ziyexiaoxiao 2020-10-14
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28