Direct data transfer activity

All data in the software can not be on the same page or processed in the same class, which involves the transmission of data directly in the web in the future after the data to be passed to the data processing field is passed through the form form Android directly in the transmission of data through the Bundle the data down to the stack for data transfer, then. getIntent (). getExtras () to get to the inside of the data, the following is a simple transfer of data between. First place in the first two EditView an activity and then the user through the input data and spread to the other two in an activity and then calculate and display the results of two numbers define the first two EditView in main.xml and a Button
<? Xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns: android = ""
android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: text = "calculated data"
android: id = "@ + id/data1"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: id = "@ + id/data2"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: id = "@ + id / button"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: text = "Computing"
</ LinearLayout>
Create the first activity class

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 ActivityData extends Activity {
/ ** Called when the activity is first created. * /

private Button button;

@ Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
button = (Button) findViewById (;

button.setOnClickListener (new OnClickListener () {

public void onClick (View v) {

EditText data1 = (EditText) findViewById (;
EditText data2 = (EditText) findViewById (;
Intent intent = new Intent ();
Bundle bundle = new Bundle ();

bundle.putString ("value1", data1.getText (). toString ());
bundle.putString ("value2", data2.getText (). toString ());

intent.putExtras (bundle);
intent.setClass (ActivityData.this, ResultActivity.class);
startActivity (intent);
ActivityData.this.finish ();
And the user-entered data on the Bundle Intent to pass through to another activity
Also in the layout folder in which to create a mylayout.xml configuration file to add a label with a display EditView shows the results
<? Xml version = "1.0" encoding = "utf-8"?>
xmlns: android = ""
android: layout_width = "fill_parent"
android: layout_height = "fill_parent">

android: id = "@ + id / result"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"

</ LinearLayout>
Create another to receive data activity

import android.os.Bundle;
import android.widget.TextView;

public class ResultActivity extends Activity {

@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.mylayout);

Bundle bundle = this.getIntent (). GetExtras ();

Double data1 = Double.parseDouble (bundle.getString ("value1"));
Double data2 = Double.parseDouble (bundle.getString ("value2"));

Double result = data1 + data2;
TextView textView = (TextView) findViewById (;
textView.setText ("result ========" + result);

Activity for the first pass over the data to calculate and display the results in AndroidManifest.xml registered activity
<? Xml version = "1.0" encoding = "utf-8"?>
<Manifest xmlns: android = ""
package = ""
android: versionCode = "1"
android: versionName = "1.0">
<uses-sdk android:minSdkVersion="4" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
<Activity android: name = ". ActivityData"
android: label = "@ string / app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</ Intent-filter>
</ Activity>
<activity android:name=".ResultActivity"> </ activity>
</ Application>
</ Manifest>
Results of the implementation plans

Direct data transfer activity

Direct data transfer activity

分类:Industry 时间:2011-09-19 人气:136
blog comments powered by Disqus


  • FLEX read xml with a xmlns namespace 2011-09-28

    With the XML namespace <?xml version="1.0" encoding="UTF-8"?> <root version="1" xmlns=""> <users> <user> <user_name name="zzz"> Joe Smith </user_name&g

  • Code records (XML documents on a regular scan and insert the data table) 2011-01-05

    Sorry, you Tell me, this is for their own look, not many comments. <? Php include ('/ jtxm / web / config / config.php'); / / Root directory $ Root = '/ jtxm / server /'; $ PetDir = '/ common / item / xml /'; / / Update the pet name of the log $ PetN

  • Jdom create XML file persistent data, program data to disk 2010-05-12

    Theme Description: This article details how to use the JAVA Jdom the org.jdom.output package XMLOutputter Format class with class and create a XML file data in program Requirements: Process is a list writeXml collection, save a number of "① students

  • Use custom connection. For xml path ('') and the stuff displays multiple lines of data to merge row 2010-10-27

    -- Use custom connection .for xml path('') And the stuff that displays multiple lines of data to the combined line -- Note --1. Computed column can not contain aggregate functions directly in displays, such as the following statement val. --2.for xml

  • JAXB: Use annotation binding XML (xmlns) 2010-06-29

    Java development in the use of XML almost every programmer will encounter, we choose the database currently available, there are many, including, dom4j, jaxen, SAX, etc. This article describes how to use JAXB to Object-XML mapping. JAXB is currently

  • AndroidManifest.xml配置文件解析 2014-09-18

    AndroidManifest.xml配置文件对于Android应用开发来说是非常重要的基础知识,本文将详细介绍,需要了解的朋友可以参考下 AndroidManifest.xml配置文件对于Android应用开发来说是非常重要的基础知识,本文旨在总结该配置文件中重点的用法,以便日后查阅.下面是一个标准的AndroidManifest.xml文件样例. <?xml version="1.0" encoding="utf-8"?> <manifest&

  • ajax input prompt implementation 2009-03-07

    Projects have used at the time entered by the user to give some tips, suggesting that the contents are extracted from the database (in Chinese). So a google search under the amended part of their code to share with you. Attachment is available at the

  • (Transfer) android manifest.xml meaning of elements 2010-07-20

    Transfer from Whether to allow the activity to replace the task of subordination, such as short message from the task of switching to the browser task. -------------------------------------

  • I am bitter jquery + js + xml + servlet + jsp (html) experience 2010-08-07

    <% @ Page language = "java" import = "java.util .*" pageEncoding = "utf-8"%> <% String path = request.getContextPath (); String basePath = request.getScheme ()+"://"+ request.getServerName ()+":"+

  • spring generated pdf and excel, configure the correct configuration web.xml 2010-11-18

    package com.execl; import java.util.Date; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellS

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 黔ICP备15002463号-1

processed in 0.126 (s). 14 q(s)