Hello. I decided to try in Android Studio to make a simple client for the site N. I would like to know how to implement this: Display only the text and pictures that we need in Layaut and insert them into our design, i.e. we make out how we want buttons, divas and so on. For example, there is a menu on the page, but we don’t need it, how can it not be displayed and links should be entered into its menu? I read some articles here, but I did not find exactly that. Thank you in advance.
- Link to articles not added. - Kirill Stoianov
- Links on the right of the page or in tags you can see - KodYeti
- I meant the link in the question, you write. I read some articles here, but here does not lead anywhere - Kirill Stoianov
- I considered them unnecessary in my question, since they do not contain a specific answer - KodYeti
- If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky ♦
|
1 answer
First you need to get the source code of the site page N.
URLConnection i1 = new URL("Ссылка на твой сайт N").openConnection(); i1.addRequestProperty("User-Agent", "MyBrowser/1.0"); StringBuilder i2 = new StringBuilder(); BufferedReader i3 = new BufferedReader(new InputStreamReader(i1.getInputStream())); while (true) { String i4 = i3.readLine(); if (i4 != null) { i2.append(i4); i2.append(System.lineSeparator()); } else { break; } } i3.close(); Let the source code of the unnecessary menu be like this:
<div class="menu"> <button>Первая кнопка</button> <button>Вторая кнопка</button> <button>Третья кнопка</button> </div> Then we need to remove it from the received StringBuilder i2 source code.
String[] i4 = "".toString().split(" <div class=\"menu\">" + System.lineSeparator() + " <button>Первая кнопка</button>" + System.lineSeparator() + " <button>Вторая кнопка</button>" + System.lineSeparator() + " <button>Третья кнопка</button>" + System.lineSeparator() + " </div>"); Then install the source code for your WebView .
WebView i5 = new WebView(Main.this); i5.loadData(i4[0] + i4[1], "text/html", null); - For me, this is the most convenient option. - nick
- It turns out in addition to the menu, you can delete other unnecessary items? - KodYeti
- Yes. You can delete other elements in the same way, only you need to know their source code. - nick
- the source code is there, the method is quite interesting)) How can I try to accomplish my goal) Thank you! - KodYeti
- There is another option to work with the jsoup library - maratsoft
|