package com.example.ttt;import com.example.test.R;import androID.os.Bundle;import androID.app.Activity;import androID.content.Intent;import androID.vIEw.Menu;import androID.vIEw.VIEw;import androID.Widget.TextVIEw;public class MainActivity extends Activity { @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); } public voID regist(VIEw v) { // Todo auto-generated method stub Intent intent=new Intent(this,RegistActivity.class); startActivityForResult(intent, 1);//当有多个请求的时候,标识的 } @OverrIDe protected voID onActivityResult(int requestCode, int resultCode, Intent intent) { // Todo auto-generated method stub if(requestCode==1&&resultCode==1){ String name=intent.getStringExtra("name"); int age=intent.getIntExtra("age", 0); String text="你的姓名是"+name+"你的年龄是"+age; ((TextVIEw)(findVIEwByID(R.ID.textVIEw1))).setText(text); } } }
package com.example.ttt;import com.example.test.R;import androID.app.Activity;import androID.content.Intent;import androID.os.Bundle;import androID.vIEw.VIEw;import androID.Widget.EditText;import androID.Widget.TextVIEw;public class RegistActivity extends Activity { protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.regist); } public voID click(VIEw v) { Intent intent = new Intent(); String name = ((EditText) findVIEwByID(R.ID.editText1)).getText() .toString(); int age = Integer.parseInt(((EditText) findVIEwByID(R.ID.editText2)) .getText().toString()); intent.putExtra("name", name); intent.putExtra("age", age); setResult(1, intent); finish(); }}
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:paddingBottom="@dimen/activity_vertical_margin" androID:paddingleft="@dimen/activity_horizontal_margin" androID:paddingRight="@dimen/activity_horizontal_margin" androID:paddingtop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextVIEw androID:ID="@+ID/textVIEw1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="你的注册信息是" /> <button androID:ID="@+ID/btn1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignParentleft="true" androID:layout_centerVertical="true" androID:text="注册" androID:onClick="regist"/></relativeLayout>
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:paddingBottom="@dimen/activity_vertical_margin" androID:paddingleft="@dimen/activity_horizontal_margin" androID:paddingRight="@dimen/activity_horizontal_margin" androID:paddingtop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <EditText androID:ID="@+ID/editText1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignBaseline="@+ID/textVIEw1" androID:layout_alignBottom="@+ID/textVIEw1" androID:layout_alignParentRight="true" androID:ems="10" /> <TextVIEw androID:ID="@+ID/textVIEw1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignParentleft="true" androID:layout_alignParenttop="true" androID:layout_margintop="74dp" androID:text="姓名" /> <EditText androID:ID="@+ID/editText2" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignleft="@+ID/editText1" androID:layout_below="@+ID/editText1" androID:layout_margintop="33dp" androID:ems="10" /> <TextVIEw androID:ID="@+ID/textVIEw2" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignBaseline="@+ID/editText2" androID:layout_alignBottom="@+ID/editText2" androID:layout_alignleft="@+ID/textVIEw1" androID:text="年龄" /> <button androID:ID="@+ID/button1" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_below="@+ID/editText2" androID:layout_centerHorizontal="true" androID:layout_margintop="91dp" androID:onClick="click" androID:text="返回" /></relativeLayout>总结
以上是内存溢出为你收集整理的页面交互,注册信息全部内容,希望文章能够帮你解决页面交互,注册信息所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)