You can use intent and pass the value to the next Activity. You only inflate the layout but that is not added to Activity.
You will have to get the reference to RelativeLayout
and add the inflated view to it
Have a id for RelativeLAyout
<RelativeLayout android:id="@+id/relativelayout
Then
RelativeLayout rl = (RelativeLayout) findViewById(R.id.relativeLayout);
View vi = inflater.inflate(R.layout.layout2, null); //log.xml is your file.
TextView tv = (TextView)vi.findViewById(R.id.text1);
tv.setText("hELLLLOO");
rl.addView(vi);
You may also use the
http://www.curious-creature.org/2009/02/25/android-layout-trick-2-include-to-reuse/
Or
In MainActivity
Intent intent = new Intent(MainActivity.this,SecondActivity.class);
intent.putExtra("key","hello");
startActivity(intent);
Then in SecondActivity
// Inflate Layout 2 and set text to textview.
String value = getIntent().getStringExtra("key");