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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值