0

I use a Tab Layout display two .swf files and a imageView in three tabs. However, when I wanted to change to imageView from a swf tab. The swf still exits.

//TabActivity

public class TabSwfActivity extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, OperatorActivity.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("artists").setIndicator("artists")
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, LearningActivity.class);
        spec = tabHost.newTabSpec("albums").setIndicator("albums")
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, QuestionActivity.class);
        spec = tabHost.newTabSpec("songs").setIndicator("songs")
                      .setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(2);
    }
}

//main.xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
    </LinearLayout>
</TabHost>

//swf tab learningActivity.java

public class LearningActivity extends Activity {
private WebView mWebView;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.learninglayout);   
    String url ="file:///android_asset/sample/simple.swf";
    mWebView=(WebView) findViewById(R.id.webView1);
    mWebView.getSettings().setPluginsEnabled(true);
    mWebView.loadUrl(url);
  }

}

// learning.xml

<?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"
    >
<WebView android:id="@+id/webView1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">
</WebView>
</LinearLayout>

//picture tab

public class QuestionActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.questionlayout);
    }
}
Sam
  • 964
  • 3
  • 11
  • 24
  • @quingfeng the question is not clear. You are starting with questionactivity tab as active ( I assume this is the one with imageview). – user994886 Dec 04 '11 at 07:58
  • I want to switch between a flash file and a picture in Tabhost Widget.However when I clicked the flash tab(the flash is loaded which contains by a webview)then the flash will still be in front of the screen even if I clicked the picture tab.The picture will always under the flash. – Sam Dec 05 '11 at 10:40
  • Looks like you have problem pausing flash. Hope this link will provide you some leads http://stackoverflow.com/questions/3431351/how-do-i-pause-flash-content-in-an-android-webview-when-my-activity-isnt-visibl – user994886 Dec 07 '11 at 03:50

0 Answers0