You can use FrameLayout ; so both views will be placed on top of the other. Then you can switch their visibility using the View.setVisibility(..) method.
[EDIT: ADDED CODE]
This is my XML layout (weblister.xml):
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/list_view" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </FrameLayout>
Now I am creating an Activity that will have both ListView and WebView in its view hierarchy, but only one of them will be visible:
public class WebAct extends Activity { @Override protected void onCreate(Bundle savedInstanceState) {
Note. The code may not be complete, but I hope it conveys my point.
Samuh source share