activity main_XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/FrameLayout1"
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"
android:background="@drawable/dback"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="first name"
android:layout_marginLeft="25dp"
android:layout_marginTop="100dp"
android:textColor="#FFFFFF"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="last name"
android:textColor="#FFFFFF"
android:layout_marginLeft="25dp"
android:layout_marginTop="200dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:layout_marginTop="100dp"
android:textColor="#FFFFFF"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="150dp"
android:layout_marginTop="200dp"
android:textColor="#FFFFFF"
android:ems="10" />
<Button
android:id="@+id/button1"
android:layout_width="80dp"
android:layout_height="45dp"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/editText2"
android:layout_marginTop="78dp"
android:background="@drawable/save" />
</RelativeLayout>
view_XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/FrameLayout1"
android:layout_width="match_parent"
android:background="@drawable/yback"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="100dp"
android:shadowColor="#ff2548"
android:textEditNoPasteWindowLayout="@layout/view"
android:textSize="30dp"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:text="text" />
<Button
android:id="@+id/button1"
android:layout_width="80dp"
android:layout_height="45dp"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:background="@drawable/back"
android:layout_marginTop="109dp"
/>
</RelativeLayout>
Main activity_java
package com.example.passvalue;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity implements OnClickListener {
EditText etFName;
EditText etLName;
Button btnSubmit;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etFName = (EditText) findViewById(R.id.editText1);
etLName = (EditText) findViewById(R.id.editText2);
btnSubmit = (Button) findViewById(R.id.button1);
btnSubmit.setOnClickListener(this);
}
public void onClick(View v) {
Intent intent = new Intent(this,viewactivity.class);
intent.putExtra("fname", etFName.getText().toString());
intent.putExtra("lname", etLName.getText().toString());
startActivity(intent);
}
}
View activity_java
package com.example.passvalue;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class viewactivity extends Activity {
TextView tvView;
Button back;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view);
tvView = (TextView) findViewById(R.id.textView1);
Intent intent = getIntent();
String fName = intent.getStringExtra("fname");
String lName = intent.getStringExtra("lname");
tvView.setText("Your name is: " + fName + " " + lName);
back = (Button) findViewById(R.id.button1);
back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(viewactivity.this, MainActivity.class);
startActivity(i);
}
});
}
}
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class viewactivity extends Activity {
TextView tvView;
Button back;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view);
tvView = (TextView) findViewById(R.id.textView1);
Intent intent = getIntent();
String fName = intent.getStringExtra("fname");
String lName = intent.getStringExtra("lname");
tvView.setText("Your name is: " + fName + " " + lName);
back = (Button) findViewById(R.id.button1);
back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(viewactivity.this, MainActivity.class);
startActivity(i);
}
});
}
}