I want to display a DisclaimerActivity on my app using webview; app which has an inbuilt sqlite database (where one table contain my disclaimer info and is defined by 4 columns and a single row as follow: discID INT, discEN memo, discHU memo discRO memo).
on its related layout xml i defined the webview for this memo field
<WebView
android:id="@+id/detail_disclaimer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/vgap"
android:textColor="@color/FG_Dark"
android:textSize="@dimen/normal_text"
tools:ignore="WebViewLayout" />
on my databaseHelper.java i have declared a cursor for this disclaimer select:
public Cursor getDisclaimer(String where) {
Cursor c = myDataBase.rawQuery("select * from disclaimer " + where,
null);
return c;
}
but i really don't know how to continue with the DisclaimerActivity.java . Since this app already exist and works with this inbuilt database, (with other tables), i "stolen" from there a piece of code and i have an idea about how this piece of code should look but is far from being correct:
public class DisclaimerActivity extends TranslatableActivity {
private int id;
private String _disclaimer = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_disclaimer);
id = getIntent().getIntExtra("ID", -1);
setData(id);
}
private void setData(int ID) {
databaseHelper db;
try {
db = new databaseHelper(getApplicationContext());
db.opendatabase();
Cursor cur = db.getDisclaimer("where discID = " + id);
}
cur.close();
WebView disclaimer = ((WebView) findViewById(R.id.detail_disclaimer));
disclaimer.loadData(
"<html><head><meta charset=\"ISO-8859-1\" /></head><body><div align=\"justify\"><font size=\"4pt\" color=\"007600\">"
+ _disclaimer
+ "</font>"
+ "</div></body></html>",
"text/html; charset=UTF-8", null);
disclaimer.setWebViewClient(new WebViewClient() {
});
db.close();
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Can someone help me out with this code to be able to display the memo field on this mentioned webview layout, and even more, to be able to display it according to the current language which is currently chosen?
for more information, piece of codes, dont hesitate to ask me and if i can provide it, ill gladly try to help.
Aucun commentaire:
Enregistrer un commentaire