2012-08-10 86 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

相关问题