Exemplo n.º 1
0
 @Override
 public void loadData() {
   CommonUtil.loadUrl(WebViewActivity.this, url, webView);
 }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browse_info_webview);
    catInfoTitle = (TextView) this.findViewById(R.id.catInfoTitle);
    catInfoTitle.setText(getResources().getString(R.string.price));
    webView = (WebView) this.findViewById(R.id.catInfoWebView);

    Intent intent = getIntent();
    info = (Info) intent.getSerializableExtra("info");
    location = intent.getIntExtra("location", 0);
    charset = intent.getStringExtra("charset");
    String content =
        "<center><h3>"
            + info.getTitle()
            + "</h3>作者:"
            + info.getAuthor()
            + "   来源:"
            + info.getSource()
            + "</center>";
    content += info.getContent();
    CommonUtil.loadData(this, content, "text/html", charset, webView, true, true, false);

    nextInfoButton = (ImageButton) findViewById(R.id.nextInfoButton);
    CommonUtil.setButtonFocusChanged(nextInfoButton);
    nextInfoButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (location + 1 > (AppCache.keyListMap.get(AppCache.PRICE).size() - 1)) { // 即下一篇资讯的位置
              Toast.makeText(BrowsePriceActivity.this, "已经是最后一篇文章了", Toast.LENGTH_SHORT).show();
            } else {
              new Thread() {
                public void run() {
                  location += 1;
                  HashMap<String, String> map =
                      AppCache.keyListMap.get(AppCache.PRICE).get(location);
                  int infoId = Integer.parseInt(map.get(PriceBuyActivity.URL_OR_INFOID));
                  Info info = InfoActivity.getInfoWithContentById(infoId, charset);
                  if (null == info) return;
                  String content =
                      "<center><h3>"
                          + info.getTitle()
                          + "</h3>作者:"
                          + info.getAuthor()
                          + "   来源:"
                          + info.getSource()
                          + "</center>";
                  content += info.getContent();
                  CommonUtil.loadData(
                      BrowsePriceActivity.this,
                      content,
                      "text/html",
                      charset,
                      webView,
                      true,
                      true,
                      false);
                };
              }.start();
            }
          }
        });
  }