In your FirstActivity say main activity you have a editext and a button. User enters the values in editext. On Button click get that value. Use intents to pass the value to the secondactivity. In second activity retrieve the value and display the same in textview.
addView.setOnClickListener(new OnClickListener()
{
Intent i= new Intent("com.example.secondActivity");
// Package name and activity
// Intent i= new Intent(MainActivity.this,SecondActivity.Class);
// Explicit intents
i.putExtra("key",editext.getText().toString());//get value from editext
// Parameter 1 is the key
// Parameter 2 is your value
startActiivty(i);
});
In your second Activity retrieve it:
Bundle extras = getIntent().();
if (extras != null) {
TextView tv= (TextView) findViewById(R.id.textview)
String value = extras.getString("key");
//get the value based on the key
tv.setText(value);
}
Edit: In your second activity you can do something similar as below
second.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="74dp"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:id="@+id/ll"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="157dp"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
SecondActivity
public class SecondActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
LinearLayout ll = (LinearLayout) findViewById(R.id.ll);
Bundle extras = getIntent().getExtras();
if(extras!=null)
{
TextView tv= new TextView(this);
tv.setText(extras.getString("key").toString());
ll.addView(tv);
}
}
}