簡體   English   中英

以編程方式打開Android數字鍵盤

[英]Open Android numeric keyboard programmatically

如何以編程方式打開Android的數字鍵盤?

我知道如何將EditText設置為數字並啟動數字鍵盤,但是我想要一個沒有EditText或Layout的解決方案,因為我正試圖為Webview打開鍵盤。

你嘗試過這個嗎?

  InputMethodManager inputMethodManager =
  (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(linearLayout.getApplicationWindowToken(),
    InputMethodManager.SHOW_FORCED, 0);

這到你的oncreate()

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

嘗試這個

EditText etxt = new EditText(this);

etxt.setInputType(InputType.TYPE_CLASS_NUMBER);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM