package com.example.firstpg.firstpg;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
import android.content.Intent; public class FirstlayoutActivity extends ActionBarActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.firstlayout);
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_firstlayout, menu);
return true ;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId(); //noinspection SimplifiableIfStatement
switch (id)
{
case R.id.add_item:
Toast.makeText(this,"大海啊大海",Toast.LENGTH_SHORT).show();
break;
case R.id.edit_item:
Intent intent=new Intent(FirstlayoutActivity.this,SecondlayoutActivity.class);
startActivity(intent);
break;
case R.id.del_item:
Intent intent2=new Intent(FirstlayoutActivity.this,SecondlayoutActivity.class);
intent2.putExtra("data1", "你好1");
startActivityForResult(intent2,1);
break;
default:
finish();
} return super.onOptionsItemSelected(item);
}
protected void onActivityResult(int requestCode,int resultCode,Intent data)
{
switch (requestCode) {
case 1:
if (resultCode == RESULT_OK) {
String retrundata = data.getStringExtra("data2");
Log.d("data2", retrundata);
}
break;
}
}
}
package com.example.firstpg.firstpg;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button; public class SecondlayoutActivity extends ActionBarActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.secondlayout);
Intent intent=getIntent();
String data=intent.getStringExtra("data1");
Log.d("data1", data);
Button button2=(Button)findViewById(R.id.button2);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intert=new Intent();
intert.putExtra("data2","你好2");
setResult(RESULT_OK,intert);
finish();
}
});
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_secondlayout, menu);
return true;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId(); //noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
} return super.onOptionsItemSelected(item);
}
}
    
<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FirstlayoutActivity"> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_centerHorizontal="true"
android:layout_marginTop="195dp" /> </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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.firstpg.firstpg.SecondlayoutActivity"> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" /> </RelativeLayout>

menu

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".FirstlayoutActivity">
<item android:id="@+id/add_item" android:title="添加" />
<item android:id="@+id/edit_item" android:title="修改" />
<item android:id="@+id/del_item" android:title="回传数据测试" />
<item android:id="@+id/return_item" android:title="退出" />
</menu>

android 页面跳转,数据回传的更多相关文章

  1. Android页面之间进行数据回传

    要求:页面1跳转到页面2,页面2再返回页面1同时返回数据 页面1添加如下代码: Intent intent = new Intent(); intent.setClass(页面1.this, 页面2. ...

  2. Android 页面跳转之生命周期调用顺序问题

    Android Activity 常用技巧 Android Activity 启动模式和任务栈 Android 页面跳转之生命周期调用顺序问题 一.页面跳转逻辑分析 1.1 跳转逻辑分析 Androi ...

  3. 【swift学习笔记】二.页面转跳数据回传

    上一篇我们介绍了页面转跳:[swift学习笔记]一.页面转跳的条件判断和传值 这一篇说一下如何把数据回传回父页面,如下图所示,这个例子很简单,只是把传过去的数据加上了"回传"两个字 ...

  4. Android first --- 页面跳转及数据传递

    页面跳转即数据传递 创建第二个界面Acivity *需要在清单文件中添加配置一个Actuvity标签 标签中如果带有这个子节点,则会在Android中添加一个快捷图标 <intent-filte ...

  5. Android 完美解决bundle实现页面跳转并保留之前数据+传值

    1.前言 前言: 昨天碰到了一个问题,我想实现页面跳转,采用了Bundle之后,再回到原来的页面,发现数据也没有了, 而且一直报错,网上查找了很多资料,发现要用一个startActivityForRe ...

  6. Android成长日记-使用Intent实现页面跳转

    Intent:可以理解为信使(意图),由Intent来协助完成Android各个组件之间的通讯 Intent实现页面之间的跳转 1->startActivity(intent) 2->st ...

  7. Android实现页面跳转、ListView及其事件

    Android实现页面跳转.ListView及其事件 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 工程内容 进入主页面后,使用ListView实现特 ...

  8. Android+Jquery Mobile学习系列(4)-页面跳转及参数传递

    关于页面转场,这个必须得专门列出来说明一下,因为Jquery Mobile与普通的Web发开有一些区别,这个对于新手如果不了解的话,就会钻到死胡同.撸主前段时间就是很急躁地上手开发程序,结果在页面转场 ...

  9. Android中实现activity的页面跳转并传值

    一个Android应用程序很少会只有一个Activity对象,如何在多个Activity之间进行跳转,而且能够互相传值是一个很基本的要求. 本次我们就讲一下,Android中页面跳转以及传值的几种方式 ...

随机推荐

  1. StringGrid 实例1:初始化StirngGrid的首行和首列

    实例1:初始化StirngGrid的首行和首列

  2. Silverlight 4常用StringFormat格式总结

    原文地址:http://www.silverlightchina.net/html/tips/2011/0424/7149.html 在Silverlight项目中,经常会根据需求的不同,提供不同的字 ...

  3. [f]添加css3动画的方法

    添加css3的一些动画的属性 使用方法: css3(oDiv[0], 'scale', 300)('rotate', 300);css3(oDiv[0], 'animation', '"dd ...

  4. Ajax跨域请求ashx文件与Webservice文件

    前台页面: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1 ...

  5. Web程序的桌面提醒

    做web开发常会面对的一个问题是,浏览器最小化的时候如何才能向用户发送通知.解决办法大概有三种:让用户有事没事儿搂两眼页面:开发一个桌面客户端:Html5的Notification API. 目前没看 ...

  6. 配置Hadoop开发环境(Eclipse)

    参考博文: http://blog.csdn.net/zythy/article/details/17397153 http://www.tuicool.com/articles/AjUZrq 注意事 ...

  7. 冲刺阶段 day 6

    项目进展:学生管理这部分已经进展的差不多了,调试了几遍,改了几个小Bug之后就没有什么问题了,基本完成,如若后续还有一些新的功能到时候再自行加入.明天开始教师部分. 存在问题:我觉得我们的项目还是比较 ...

  8. Mac OS X 安装ruby环境

    1.查看版本 $ ruby -v ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14] 2.查看源 $ gem ...

  9. [安卓] 5、SeekBar拖动条

    越来越发现这些控件用法大同小异了,这里注意几个函数:seekBar.setSecondaryProgress(0);设置初始进度为0,总共为0~99,对其监听用setOnSeekBarChangeLi ...

  10. [游戏模版10] Win32 平面地图贴图 正

    >_<:picture resource >_<:If you master the ways of mapping picture,then this problem is ...