如何从一个页面移动数据的其他Android中 [英] how to move data's from one page to the other in Android

查看:186
本文介绍了如何从一个页面移动数据的其他Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜在我的应用我已经把两个编辑框和OK按钮。在编辑框中我得到的值,如名字和第二名字。

Hi in my app i have placed two edit boxes and on OK button. In the edit boxes i am getting the values such as the first name and second name.

现在我想要做下列程序
1.当我点击按钮OK我移动到新的页面,在这里,我要显示在第一页的编辑框中输入的数据。

Now i want to do the following process 1. When i click the button OK i move over to the new page, here i want to display the data's entered in the edit boxes of the first page.

2.In第二页的标题栏,我想显示第一个编辑框输入的数据即第一个名字进入必须有第二页的标题。

2.In the title bar of the second page i want display the data entered in the first edit box ie the first name entered there must be the title of the second page.

如何做到这一点请帮助我

how to do this pls help me

推荐答案

设置OK按钮有一个OnClickListener

Set the OK Button to have an OnClickListener

public void onCreate(Bundle savedInstanceState) {
View okButton = findViewById(R.id.okButtonImg); //assume you are using custom img for OK
okButton.setOnClickListener(okButtonListener);
}

在点击监听器调用一个意图。
在意向,可以使用的信息传递putExtra

In the Click Listener invoke an Intent. In the Intent you can pass information using "putExtra"

        private OnClickListener okButtonListener = new OnClickListener() {

            public void onClick(View v) {
            Intent secondPageIntent = new Intent(getBaseContext(), SecondPage.class);
            secondPageIntent.putExtra("PASSVALUE","ANY  STRING HERE");
            startActivity(secondPageIntent);

            }
     };

在第二页使用getExtras(PASSVALUE)来检索您传递的数据

In the second page use getExtras("PASSVALUE") to retrieve data that you passed

看到这个职位的详细信息
http://mylifewithandroid.blogspot.com/2007/12/playing-with -intents.html

See this post for more details http://mylifewithandroid.blogspot.com/2007/12/playing-with-intents.html

这篇关于如何从一个页面移动数据的其他Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆