Hello. I am developing a browser that uses webview to display content. I needed to make the function of turning off the display of images, so that instead of them there were links (if you still want to see the image), how to implement a shutdown, as painlessly as possible for my code? Or at least implement it at all.

public class WebFragment extends PageFragment { /*Другой нужный код*/ @Override public void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { // Inflate the menu; this adds items to the action bar if it is present. inflater.inflate(R.menu.main, menu); @Override public boolean onOptionsItemSelected(android.view.MenuItem item) { int id = item.getItemId();//получение id if (id == R.id.cache_mode) {//id из main.xml showCacheDialog();//показ соответствующего диалога return true; } return super.onOptionsItemSelected(item);//действия при выборе пункта меню } protected void showCacheDialog() {//показываю диалог new MaterialDialog.Builder(getContext()) .title("Настройки кэша") .items(new String[]{"Кэш и сеть", "Только сеть", "Только кэш"}) .itemsCallbackSingleChoice(AppPreferences.getCacheMode() - 1, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog materialDialog, View view, int i, CharSequence charSequence) {//обработка клика AppPreferences.setCacheMode(i + 1); return false; } }) .show(); } } 

Here is the implementation of a single function (caching). I need something like this, but with the disconnection of images. (Always, only wi-fi, never) If you need a code, here is the link: link to the github Please show me an example code, or a link where you can read about it in detail. Thank you very much!

    1 answer 1

    In the HTML code displayed using WebView you need to replace all the IMG tags with A and rename their scr attributes to href .

    This can be done either with regulars (it is possible, but not necessary - do not do this) or with a library for parsing HTML. For example JSOUP.

    You can download the necessary HTML code by URL with the same JSOUP. And then display the final content in WebView .

    But there may be problems with all sorts of buttons and JS scripts.