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 = "http://schemas.android.com/apk/res/android"
android: orientation = "vertical"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
>
<TextView
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: text = "calculated data"
/>
<EditText
android: id = "@ + id/data1"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
/>
<EditText
android: id = "@ + id/data2"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
/>
<Button
android: id = "@ + id / button"
android: layout_width = "fill_parent"
android: layout_height = "wrap_content"
android: text = "Computing"
/>
</ LinearLayout>
Create the first activity class
package com.data;

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 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 (R.id.button);

button.setOnClickListener (new OnClickListener () {

public void onClick (View v) {

EditText data1 = (EditText) findViewById (R.id.data1);
EditText data2 = (EditText) findViewById (R.id.data2);
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"?>
<LinearLayout
xmlns: android = "http://schemas.android.com/apk/res/android"
android: layout_width = "fill_parent"
android: layout_height = "fill_parent">

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

</ LinearLayout>
Create another to receive data activity
package com.data;

import android.app.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 (R.id.result);
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 = "http://schemas.android.com/apk/res/android"
package = "com.data"
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">
<intent-filter>
<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

  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Direct data transfer activity

  • Process migration from tomcat to websphere changes

    Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm's

  • JAVA EE JSP_JNDI

    dsfdsa http://lindows.javaeye.com/admin/blogs/213348 Tomcat 6 with the connection pool data source configuration http://www.blogjava.net/ec2008/archive/2008/07/19/216063.html project: test Driver path: D: \ workspace \ test \ WebRoot \ WEB-INF \ lib ...

  • Hibernate.cfg.xml configuration file (including the primary key generation strategy Introduction)

    Hibernate.cfg.xml configuration file: <? xml version = "1.0" encoding = "utf-8"?> <! DOCTYPE hibernate-configuration PUBLIC "- / / Hibernate / Hibernate Configuration DTD / / EN" "hibernate-configuration-2.0.dtd

  • The EJB3 Persistence

    EJB3 persistence with Hibernate is very similar to the mechanism: Environment: Server: JBOSS5.0 Database: MySQL5.0 1. Set up a data source First of all, in jboss-5.0.0.GA \ server \ default \ deploy, the establishment of a database used to connect the dat

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @ gmail.com

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries