Я использую Tab Layout для отображения двух .swf файлов и imageView в трех вкладках.Однако, когда я хотел перейти на imageView из вкладки SWF.SWF-файл все еще завершается.
// 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 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>
// вкладка изображения
public class QuestionActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.questionlayout);
}
}