2
我在我的應用程序的webview中顯示網頁。我只想在用戶點擊/觸摸webview內的編輯文本時啓用屏幕方向。我嘗試了下面的代碼。如何獲得webview中edittext的點擊事件
mWebView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
WebView.HitTestResult hr = ((WebView)v).getHitTestResult();
if(hr!=null){
if(hr.getType()==HitTestResult.EDIT_TEXT_TYPE)
((Activity) context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
else
((Activity) context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
return false;
}
});
但它在低於2.3的操作系統版本中不起作用。我怎樣才能做到這一點在這些版本中also.please幫助我。我是卡在這個..
@seethakashmi,任何更新? – Harish