You can get data from edittext and pass it to your secondactivtiy using intents.
String s1,s2
EditText ed1= (EditText)findViewById(R.id.editext);
EditText ed2= (EditText)findViewById(R.id.editext2);
on Button click
s1 = ed1.getText().toString();
s2 = ed2.getText().toString();
ed1.setText("");
ed2.setText("");
In same activity. Can keep other tags as above.
String xml ="<AcctNo>"+s1+"</AcctNo>"
+ "<ExpDate>"+s2+"</ExpDate>";
OR
Intent i= new Intent("com.example.secondactivity");
i.putExtra("key1",s1);
i.putExtra("key2",s2);
startActivity(i);
In Second Activity you can retrieve the values.
String value1,value2;
Bundle extras = getIntent().getExtras();
if (extras != null) {
value1 = extras.getString("key1");
value2 = extras.getString("key2");
}
Can keep other tags as above.
String xml ="<AcctNo>"+value1+"</AcctNo>"
+ "<ExpDate>"+value2+"</ExpDate>";
EDIT :
acitivity_main.xml
<LinearLayout 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:orientation="vertical"
tools:context=".MainActivity" >
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="33dp"
android:ems="10" >
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:ems="10" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="36dp"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="TextView" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="Button" />
</LinearLayout>
MainActivity
public class MainActivity extends Activity {
EditText ed1,ed2;
TextView tv1,tv2,tv3;
Button b;
String s1;
String s2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed1= (EditText) findViewById(R.id.editText1);
ed2= (EditText) findViewById(R.id.editText2);
tv1 = (TextView) findViewById(R.id.textView1);
tv2 = (TextView) findViewById(R.id.textView2);
tv3 = (TextView) findViewById(R.id.textView3);
b= (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
s1= ed1.getText().toString();
s2= ed2.getText().toString();
System.out.println("................"+s1);
System.out.println("................"+s2);
tv1.setText(s1);
tv2.setText(s2);
String xml ="<AcctNo>"+s1+"</AcctNo>"
+ "<ExpDate>"+s2+"</ExpDate>";
System.out.println("................"+xml);
tv3.setText(xml);
ed1.setText("");
ed2.setText("");
}
});
}
}
As you can see it works. See the snap shot. I have 3 text views, 2 editext's and a button. After user types in editext's i click the button and i set the values to textview. As you can see the values reflects in string xml which is the result set in textview3.