I have a code, that is a website and I need to write an App, that shows just this page. But the problem is that my code didn't see the Hyperlinks because I need to change from TextView to HTMLView. this is the code:
public class BlackBoardClient {
private static final String BLACK_BOARD_URL = "https://zpa.cs.hm.edu/public/notice_board/";
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd.MM.yyyy");
public static List<BlackBoardEntry> getBlackBoardEntries() throws IOException {
List<BlackBoardEntry> entries = new ArrayList<>();
Document doc = Jsoup.connect(BLACK_BOARD_URL).get();
Element newsTable = doc.getElementById("content").selectFirst("table");
Iterable<Element> rows = newsTable.selectFirst("tbody").children();
for (Element row : rows) {
Iterator<Element> columns = row.children().iterator();
String author = columns.next().text();
String title = columns.next().text();
String content = columns.next().text();
LocalDate validFrom = LocalDate.parse(columns.next().text(), FORMATTER);
LocalDate validUntil = LocalDate.parse(columns.next().text(), FORMATTER);
BlackBoardEntry entry = new BlackBoardEntry(author, title, content, validFrom, validUntil);
entries.add(entry);
}
return entries;
}
}
It shows like this: enter image description here
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView dataList = findViewById(R.id.dataList);
dataList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
BlackBoardEntry entry = (BlackBoardEntry) parent.getItemAtPosition(position);
String content = entry.getContent();
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popupView = inflater.inflate(R.layout.content_popup, null, false);
((TextView) popupView.findViewById(R.id.contentView)).setText(content);
PopupWindow popup = new PopupWindow(popupView, 500, 1000, true);
popup.showAtLocation(parent, Gravity.CENTER, 0, 0);
}
});
new Thread(new Runnable() {
@Override
public void run() {
try {
List<BlackBoardEntry> entries = BlackBoardClient.getBlackBoardEntries();
BlackBoardAdapter adapter = new BlackBoardAdapter(entries, getApplicationContext());
dataList.post(new Runnable() {
@Override
public void run() {
dataList.setAdapter(adapter);
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
}