Hi!
Looks like that I had quite the same problem like you ... it's simply not working to replace the whole content with "this.setContentView(view)" (uuuhh ... or at least I had some problems with it).
I'm going to show you what I've done ... I'm not creating the second view (for result-displaying in my case) in runtime but I'm switching between two views by showing and hinding them.
my "main.xml":
Using xml Syntax Highlighting
<?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"
android:background="@drawable/background"
>
<LinearLayout
id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<!-- More Content here -->
</LinearLayout>
<LinearLayout
id="@+id/resultlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<!-- More Content here -->
</LinearLayout>
</LinearLayout>
Parsed in 0.003 seconds, using
GeSHi 1.0.8.4
Ok, I have defined my two views/layouts in main.xml ... on startup "mainlayout" will be displayed and should be replaced by "resultlayout". In fact I'm just hiding "mainlayout" and displaying "resultlayout".
Using java Syntax Highlighting
private void generateMainView() {
LinearLayout mainLayout = (LinearLayout)findViewById(R.id.mainlayout);
LinearLayout resultLayout = (LinearLayout)findViewById(R.id.resultlayout);
// Enable Main & Disable Result
resultLayout.setVisibility(View.GONE);
mainLayout.setVisibility(View.VISIBLE);
}
private void generateResultView() {
LinearLayout mainLayout = (LinearLayout)findViewById(R.id.mainlayout);
LinearLayout resultLayout = (LinearLayout)findViewById(R.id.resultlayout);
// Enable Main & Disable Result
resultLayout.setVisibility(View.VISIBLE);
mainLayout.setVisibility(View.GONE);
}
Parsed in 0.032 seconds, using
GeSHi 1.0.8.4
This works fine for me but I guess it wouldn't probably fit for you.
I've not tested it but you could try the following ...
1. Get the mainLayout like I did.
Using java Syntax Highlighting
mainLayout = (LinearLayout)findViewById(R.id.mainlayout);
Parsed in 0.030 seconds, using
GeSHi 1.0.8.4
2. Try to add you "additional" view to the "mainLayout".
Using java Syntax Highlighting
mainLayout.addView(child);
Parsed in 0.033 seconds, using
GeSHi 1.0.8.4
Could probably work
Cheers
-kao-