这是我的WebActivity.class
。我知道要加载特定的URL,我们必须使用:
webView.loadUrl("file:///android_asset/about.html");
使用WebActivity.class
从另一个活动调用 Intent
。
Intent intent = new Intent(this, WebActivity.class);
startActivity(intent);
我想做的是,是否可以提出类似的内容:
webView.loadUrl(url);
然后在我的另一项活动中,我将网址放入了意图中,以便在WebActivity.class
中加载网址?
Intent intent = new Intent(this, WebActivity.class);
url="file:///android_asset/about.html";
startActivity(intent);
答案 0 :(得分:6)
如果我理解正确的话......试试这个..
在你的MainActivity中,像这样调用你的意图..
<!DOCTYPE html>
<html>
<head>
<!-- head stuff here -->
</head>
<body class="total">
<div id="wrapper" class="leftSidePane">
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
</li>
<li>
</li>
<li>
</li>
</ul>
</div>
</div>
<div class="content">
<div class="mainContent">
<h1>
WWW.SITE.COM
</h1>
<h2>dedicated to stuff</h2>
<p style="text-align: center;
color: #5D5D5D;">last updated: 01.01.2016</p>
<br>
<p style="
font-family: 'Times New Roman';
color: #C1C1C1;
font-weight: bold;
font-size: 20px;
text-align: center;
">Site visited 27 times</p>
<br><br>
<hr>
</div>
</div>
<div class="rightSidePane">
<!-- Side bar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand-right">
</li>
<li>
<a href="#">
</a>
</li>
<li>
<div class="barfix"></div>
</li>
<li class="board">
</li>
<li class="nextBar">
</li>
<li>
<div class="tileRightInit" id="bs">
<div class="barTextRight">MAIN</div>
</div>
</li>
<li>
<div class="tileRight" id="bs">
<div class="barTextRight">News</div>
</div>
</li>
<li>
<div class="tileRight" id="bs">
<div class="barTextRight">Links</div>
</div>
</li>
<li>
<div class="tileRight" id="bs">
<div class="barTextRight">Credits</div>
</div>
</li>
<li>
<div class="tileRight" id="bs">
<div class="barTextRight">About</div>
</div>
</li>
<li class="bottomRight">
</li>
</ul>
</div>
</div>
</body>
</html>
在您的Intent intent = new Intent(this, WebActivity.class);
intent.putExtra("url","file:///android_asset/about.html");
startActivity(intent);
中,只需获取WebActivity.clss
Extras
完成。