Example #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    String title = getIntent().getExtras().getString("title");
    int selectedId = getIntent().getExtras().getInt("id");

    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.drug_info);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title_without_search);

    DBHelper myDbHelper = new DBHelper(this);
    myDbHelper = new DBHelper(this);
    try {
      myDbHelper.createDataBase();
    } catch (IOException ioe) {
      throw new Error("Unable to create database");
    }
    try {
      myDbHelper.openDataBase();

      drugInfo = myDbHelper.getDrugInfoById(selectedId);

      myDbHelper.close();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    TextView headerText = (TextView) findViewById(R.id.headerTitle);
    headerText.setText(title);

    WebView drugInfoContainer = (WebView) findViewById(R.id.drugInfoWebView);
    drugInfoContainer.getSettings().setJavaScriptEnabled(true);
    String header =
        "<!DOCTYPE html>\n"
            + "<html>\n"
            + "<head>\n"
            + "    <meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />\n"
            + "</head>\n"
            + "<body style='background-color:#fefdfb'><p style='font-size:5px;'>&nbsp</p>\n"
            + drugInfo
            + "</body>\n"
            + "</html>";
    drugInfoContainer.loadDataWithBaseURL("", header, "text/html", "utf-8", null);
  }