안녕하세요.
개괄설명 :
Activity에 TabHost로 WebView하나를 가지고 있고, 해당 탭을 눌렀을때 동일한 WebView에서 URL만 변경시켜서 loadUrl합니다.
탭클릭 정상 작동합니다.
에러현상 :
1. 하나의 탭을 클릭해서 뜬 페이지에서 클릭(anchor tag)이벤트 정상작동
2. 다른탭 페이지 내에서 클릭(anchor tag) 이벤트 가 안먹어요.
3. 다시 또다른 탭 내에서 클릭(anchor tag) 이벤트 정상작동
4. 클릭이벤트 잘먹던 탭 클릭 후, 페이지 내에서 클릭(anchor tag) 이벤트 안먹음.
증상분석 : 반복적으로 클릭(anchor tag)이벤트가 먹다 안먹다 합니다.
동일한 페이지를 아이폰에서 확인결과 정상적으로 다 뜨네요.
증상원인예상 : 아무리 찾아봐도 WebView의 문제는 아닌거 같고 (LogCat에도 특별한 에러로그 없습니다. 이벤트작동이 정상적으로 뜹니다.), WebPage의 문제인거 같은데요.
웹페이지는 Jquery1.5.2 + Jquery.mobile-1.0a4.1로 구현되어있습니다.
혹시나 해서 javascriptEnable = false로 하고 해도 동일현상이네요.
혹시 이런 현상 경험해 보신분 있으시거나, 해결하신분 있으신가요?
참고로 현재 소스 올려봅니다.
----------------- layout------------------------------
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" > <WebView android:id="@+id/wv" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </FrameLayout> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="bottom" /> </LinearLayout> </TabHost>
-----------------Activity------------------------
public class MyActivity extends TabActivity implements OnTabChangeListener{
final String url1 = "http://localhost/a";
final String url2 = "http://localhost/b";
final String url3 = "http://localhost/c";
final String url4 = "http://localhost/d";
final String url5 = "http://localhost/e";
public ProgressDialog mProgress;
public WebView wv;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
//try{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mProgress = new ProgressDialog(this);
wv = (WebView)findViewById(R.id.wv);
final TabHost tabHost = getTabHost();
tabHost.setup();
TabHost.TabSpec spec;
int idx = R.id.wv;
WebSettings ws = wv.getSettings();
ws.setDefaultTextEncodingName("UTF8");
ws.setJavaScriptEnabled(false);
ws.setCacheMode(WebSettings.LOAD_NO_CACHE);
ws.setSupportZoom(false);
ws.setJavaScriptCanOpenWindowsAutomatically(true);
ws.setLoadsImagesAutomatically(true);
ws.setPluginsEnabled(true);
ws.setLightTouchEnabled(true);
ws.setBuiltInZoomControls(true);
ws.setDatabaseEnabled(true); //--- HTML5에서 Database 허용
ws.setDomStorageEnabled(true); //--- HTML5 DOM Storage 허용
ws.setAppCacheEnabled(false);
spec = tabHost.newTabSpec( "AAA" ); // 새 Tab 생성
spec.setIndicator("A", getResources().getDrawable(R.drawable.A));
spec.setContent(idx);
tabHost.addTab( spec );
spec = tabHost.newTabSpec( "BBB" ); // 새 Tab 생성
spec.setIndicator("B", getResources().getDrawable(R.drawable.B));
spec.setContent(idx);
tabHost.addTab( spec );
spec = tabHost.newTabSpec( "CCC" ); // 새 Tab 생성 spec.setIndicator("C", getResources().getDrawable(R.drawable.C)); spec.setContent(idx); tabHost.addTab( spec );
spec = tabHost.newTabSpec( "DDD" ); // 새 Tab 생성 spec.setIndicator("D", getResources().getDrawable(R.drawable.D)); spec.setContent(idx); tabHost.addTab( spec );
spec = tabHost.newTabSpec( "EEE" ); // 새 Tab 생성
spec.setIndicator("E", getResources().getDrawable(R.drawable.E));
spec.setContent(idx);
tabHost.addTab( spec );
tabHost.setOnTabChangedListener(this);
mProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mProgress.setMessage("로딩 중...역쉬 임재범 너만 가수다!!!!");
wv.setWebChromeClient(new WebChromeClient(){
public void onProgressChanged(WebView view,int progress){
mProgress.setProgress(progress);
if(progress == 100){
mProgress.hide();
} else{
mProgress.show();
}
}
});
tabHost.setCurrentTab(0);
}
@Override
public void onTabChanged(String tabId) {
if(tabId.equals("Home")){
wv.loadUrl("url1);
}else if(tabId.equals("Surround")){
wv.loadUrl("url2);
}else if(tabId.equals("Menu")){
wv.loadUrl("url3);
}else if(tabId.equals("Job")){
wv.loadUrl("url4);
}else if(tabId.equals("Myinfo")){
wv.loadUrl("url5);
}
}
}




자답!!!!!!!!!!
ws.setCacheMode(WebSettings.LOAD_NO_CACHE);
가 문제였네요.
하지만 왜 LOAD_NO_CACHE 일때 이런현상이 발생하는지는 이해가 가질 않네요.
이해되시는 분 계신가요?