안드로이드 개발 질문/답변
(글 수 45,052)
TabHost를 이용해서 탭을 만들었고 내용부분은 웹뷰로 해서 만들었습니다.
어플을 시작할때 웹뷰가 바로 떠야 하는데, 바로뜨지않고,
탭메뉴를 눌러야 그제서야 웹뷰가 뜹니다.
왜 그런가요?
아래는 소스 내용입니다.
public class FrameLayoutActivity extends TabActivity {
private View temp;
private View temp2;
private View temp3;
private View temp4;
private View temp5;
private WebView webview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.loadUrl("http://m.daum.net");
webview.setWebViewClient(new Callback());
LayoutInflater inflate = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
temp = inflate.inflate(R.layout.tab1, null);
temp2 = inflate.inflate(R.layout.tab2, null);
temp3 = inflate.inflate(R.layout.tab3, null);
temp4 = inflate.inflate(R.layout.tab4, null);
temp5 = inflate.inflate(R.layout.tab5, null);
temp.setOnTouchListener(otl);
temp2.setOnTouchListener(otl);
temp3.setOnTouchListener(otl);
temp4.setOnTouchListener(otl);
temp5.setOnTouchListener(otl);
TabHost tabhost = getTabHost();
tabhost.setBackgroundColor(Color.TRANSPARENT);
tabhost.addTab(tabhost.newTabSpec("second_tab").setIndicator(temp)
.setContent(R.id.first));
tabhost.addTab(tabhost.newTabSpec("second_tab").setIndicator(temp2)
.setContent(R.id.first));
tabhost.addTab(tabhost.newTabSpec("second_tab").setIndicator(temp3)
.setContent(R.id.first));
tabhost.addTab(tabhost.newTabSpec("second_tab").setIndicator(temp4)
.setContent(R.id.first));
tabhost.addTab(tabhost.newTabSpec("second_tab").setIndicator(temp5)
.setContent(R.id.first));
tabhost.setCurrentTab(0);
}
OnTouchListener otl = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
temp.setBackgroundColor(Color.GREEN);
temp2.setBackgroundColor(Color.GREEN);
temp3.setBackgroundColor(Color.GREEN);
temp4.setBackgroundColor(Color.GREEN);
temp5.setBackgroundColor(Color.GREEN);
v.setBackgroundColor(Color.CYAN);
return false;
}
};
// new added
private class Callback extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl("url);
return(true);
}
}
}




element