问题描述:

how to disable or enable

webView.getSettings().setLoadsImagesAutomatically(true);

on Button click in android?

网友答案:

Put this inside of a button listener.

Example solution:

public class MyActivity extends Activity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.content_layout_id);

        final Button button   = (Button) findViewById(R.id.button_id);
        final WebView webview = (WebView)findViewById(R.id.webview_id);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Toggle image autoload
                boolean autoLoad = webView.getSettings().getLoadsImagesAutomatically();
                webView.getSettings().setLoadsImagesAutomatically(!autoLoad);  
            }
        });
    }
}
相关阅读:
Top