2012-08-10 89 views
2

我正在開發適用於Android的瀏覽器。如何在Android WebView的首選項中啓用/禁用Flash?

是否可以創建一個Checkbox Preference來啓用和禁用Preferences中的Flash插件(webview.setPluginsEnabled)?

<CheckBoxPreference 
android:title="Enable/Disable Flash" 
android:key="chkbox_flash" 

Here I need the code to set WebView.getSettings().setPluginsEnabled(boolean) 
to true or to false /> 
+2

在什麼設置中? – 2012-08-10 11:05:32

+0

永遠不要忘記指定你的環境。 – 2012-08-10 11:54:52

回答

0

我不發展到Android,但似乎你應該添加一個監聽到你的CheckBoxPreference這樣checkboxpreference-onclickdocs

然後你設置的插件關閉的狀態。繼承人doc。基本上,你要做的:

WebView webview = new WebView(this); 
webview.getSettings().setPluginState(PluginState.OFF); 

你不應該使用setPluginsEnabled,因爲它是deprecated。但請注意,它將禁用任何插件,而不僅僅是Flash。

+0

聽衆會是怎樣的?對不起,我只是一個初學者。 – user1590059 2012-08-10 12:54:19

+0

像這樣的東西http://stackoverflow.com/questions/6496450/android-checkbox-preference和這個http://stackoverflow.com/questions/531427/how-do-i-display-the-current-value-of -an-android-preference-in-the-preference-su – 2012-08-10 13:12:17

+0

我試過了,但沒有奏效。 – user1590059 2012-08-10 17:22:08

相關問題