我是Android开发的新手。我有索引页面,我使用div概念显示同一页面中的每个链接。
现在我想在我的应用程序中使用后退按钮。我已经开发了代码来处理div并且它正在AVD(Andriod虚拟设备5556)中工作,但如果我将*.apk
上传到我的设备中则无法正常工作。
我在等你的回复。请帮帮我。
这是我的示例代码:
HTML示例代码:
<div id="photo_playlist">
<div id="photo_playlist_home">
<div class="HomePhotoDetailsBar">
<div class="innerplay" id="innerrow10833">
<a style="text-decoration:none;" onClick="player('1');">
<div class="thm_image">
asdasdasdadadad
</div>
<div class="video_details_n">
<div class="video_details_premium">Premium</div>
<div class="photo_details_head">Zoe Duchesne</div>
<div class="video_details_premium">5 photos</div>
</div>
<div class="video_arrow">dsfsfsfss</div>
</a>
</div>
</div>
</div>
</div>
<div id="detail">
<div id="playlist"></div>
</div>
<div id="player">
<div id="photocontainer"></div>
</div>
JS示例:
function photos() {
resetPhotoPlaylist();
$('#photo_playlist').addClass('current');
$('#photo_playlist').css('display','block');
$('#photo_playlist_home').addClass('current');
$('#photo_playlist_home').css('display','block');
$('#player').css('display','none');
$('#playlist').css('display','none');
$('#detail').css('display','none');
$('#photocontainer').css('display','none');
}
function resetPhotoPlaylist() {
$('#second_playlist').removeClass('current');
$('#second_playlist').css('display','none');
$('#playlist').removeClass('current');
$('#playlist').css('display','none');
$('#photocontainer').removeClass('current');
$('#photocontainer').css('display','none');
$('#photo_playlist_home').removeClass('current');
$('#photo_playlist_home').css('display','none');
}
function back() {
history_.pop();
var previous = history_.pop();
if(history_.length==0) {
history_ = ["home"];
}
switch(previous) {
case "home" :home();break;
case "news" :news();break;
case "video" :video();break;
case "player" :player(1);break;
case "gallery" :gallery(1);break;
case "photos" :photos();break;
case "reader" :reader(1);break;
case "searchresult" :searchresult();break;
case "search" :search();break;
}
}
function addToHistory(page) {
history_.push(page);
}
Java代码:
public void onBackPressed()
{
appView.loadUrl("javascript:back();");
}
谢谢, Rajeevgandhi。小号
答案 0 :(得分:0)
尝试
appView.loadUrl("javascript:(function() { back();})()");