タブを使用して独自の Web ブラウザーを構築しています。問題は、タブを閉じて別のタブに戻り、現在のタブをクリックすると、閉じたタブのコンテンツが取得されることです。これが私のコードです:
private void addMethod() {
//tring webSiteName = getHost("http://www.google.com");
Intent openBrowser = new Intent();
openBrowser.setClass(this, WebBrowser.class);
tabHost.addTab(tabHost.newTabSpec("http://www.google.gr" + Integer.toString(z)).setIndicator("ΚΑΡΤΕΛΑ ").setContent(openBrowser));
tabHost.setCurrentTab(z);
Log.d("z",Integer.toString(z));
++z;
}
private void deleteMethod() {
// Since we can't really delete a TAB
// We hide it
int position = tabHost.getCurrentTab();
Log.d("Position",Integer.toString(position));
if (position != 0 ) {
tabHost.getCurrentTabView().setVisibility(1);
tabHost.setCurrentTab(position-1);
}
else if(position== z){
tabHost.getCurrentTabView().setVisibility(1);
tabHost.setCurrentTab(position+1);
}
Log.d("Z val in delete()",Integer.toString(z));
if(position >0)
{
tabHost.getCurrentTabView().setVisibility(View.GONE);
tabHost.setCurrentTab(position+1);
z-=1;
if(z<0)
z=0;
}
else if(position == 0)
{
tabHost.getCurrentTabView().setVisibility(View.GONE);
tabHost.setCurrentTab(position+1);
z=0;
}
else if(position == z)
{
tabHost.getCurrentTabView().setVisibility(View.GONE);
tabHost.setCurrentTab(z-1);
Log.d("Z value in final","lol");
Log.d("Pos",Integer.toString(position));
Log.d("z pos",Integer.toString(z));
z--;
}