Ho bisogno di disabilitare la softkey aperta nella mia WebView e in tutti gli edittexts in WebView (non accedo a questo perché è in WebView).Come disabilitare il softkey in WebView
Provo ad usare 'android: windowSoftInputMode = "stateAlwaysHidden"' nel mio file Manifest, ma popup della tastiera su quando clicco nel campo modificabile.
Qual è la soluzione giusta per disabilitare il softkeyboard in WebView?
EDIT:
trovo soluzione (grazie @ g00dy in questo post e @Kachi in post https://stackoverflow.com/a/9108219/1665964) una stretta tastiera dopo che è aperto:
public class ActivityBrowser extends Activity
{
private static WebView webviewHTML;
private static View viewRootHTML;
private static int iViewRootHTMLHeightDifferent;
public static Context contextBrowser;
{
contextBrowser = this;
}
public class webViewClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
if(view == webviewHTML) super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url)
{
if(view == webviewHTML) super.onPageFinished(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
if(view == webviewHTML) view.loadUrl(url);
return false;
// return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
if(view == webviewHTML) ApplicationLeta.fPopup(getString(R.string.sPopupErrorSiteOpen) + " : " + description);
// ActivityBrowser.this.finish();
}
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
{
if(view == webviewHTML) handler.proceed();
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent motionEvent)
{
super.dispatchTouchEvent(motionEvent);
if(motionEvent.getAction() == MotionEvent.ACTION_MOVE) return true;
if(motionEvent.getAction() == MotionEvent.ACTION_UP)
{
// do something
}
if(motionEvent.getAction() == MotionEvent.ACTION_UP)
{
// do something
}
return false;
}
@Override
public void onBackPressed()
{
}
@Override
public void onWindowFocusChanged(boolean eFocus)
{
super.onWindowFocusChanged(eFocus);
if(eFocus == false)
{
fKeyboardClose();
new Thread(new Runnable()
{
@Override
public void run()
{
try
{
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
}
catch(Exception e) {}
}
}).start();
}
}
private void fKeyboardClose()
{
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
public OnGlobalLayoutListener onGlobalLayoutListener = new OnGlobalLayoutListener()
{
@Override
public void onGlobalLayout()
{
Rect rect = new Rect();
viewRootHTML.getWindowVisibleDisplayFrame(rect);
iViewRootHTMLHeightDifferent = viewRootHTML.getRootView().getHeight() - (rect.bottom - rect.top);
if(iViewRootHTMLHeightDifferent > 50) fKeyboardClose();
}
};
@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.browser);
if(savedInstanceState == null)
{
viewRootHTML = findViewById(R.id.linearLayoutHTML);
viewRootHTML.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
webviewHTML = (WebView) findViewById(R.id.webviewHTML);
WebSettings webSettings = webviewHTML.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webviewHTML.setWebViewClient(new wiewClient());
webviewHTML.loadUrl(ApplicationLeta.sAppInterviewURL);
}
}
}
Questo codice anche vicino messaggio di sistema " Modifica testo/Metodo di inserimento "quando l'utente pigia sul campo di inserimento.
Ma! Questo codice chiude la tastiera solo dopo l'apertura. La tastiera rimane visibile per alcuni millisecondi e l'utente (utente veloce) può premere qualsiasi tasto sulla tastiera. Questa non è la situazione migliore.
Forse esiste il modo migliore per disabilitare al 100% la tastiera senza aprirla?
non ho accesso a cambiare gli attributi del EditText perché ho solo il mio WebView. –
Quindi non si dispone dei diritti per modificare gli attributi di 'EditText', che si trova all'interno di un' WebView', a cui si ha accesso - come mai? Qual è il contenuto di 'WebView'? Stai visualizzando una pagina web sotto il tuo controllo o un'altra pagina web casuale? – g00dy
Dovresti invece provare a rilevare il clic, modifico il mio post. – g00dy