2016-09-01 8 views
1

ビューを使用したアプリを作成しましたが、ビューをタッチしたときにキーボードがポップアップするようにしました。つまり、ユーザー名、住所、電話の表示次のコード行を使用しましたが、アンドロイドでポップキーボード

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

これは動作しませんし、私はこれで私を助けてください、あまりにも次のことを試してみましたませんが、何の助け

((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)) 
      .showSoftInput(username, InputMethodManager.SHOW_FORCED); 

This is the image of my custom view app

私のEditText XMLは、ここに

<com.github.florent37.materialtextfield.MaterialTextField  
     android:layout_below="@+id/view" 
     app:mtf_image="@drawable/phon" android:id="@+id/view3"> 
<EditText android:layout_width="wrap_content" 
      android:layout_height="40dp" 
      android:id="@+id/phoneNo" 
      android:focusableInTouchMode="true" 
      android:textSize="18sp" 
      android:inputType="phone" 
      android:background="@drawable/phone" 
      android:hint="Phone Number" /> 
</com.github.florent37.materialtextfield.MaterialTextField> 
+0

レイアウトでEditTextを使用していますか: –

+0

はい編集テキストを使用しています。 –

+0

はあなたのeditTextユーザー名ですか? –

答えて

0

で、次の試してみてください。

mMessageはあなたのEditTextです
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
     inputMethodManager.toggleSoftInputFromWindow(mMessage.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0); 

+0

また、キーボードを開くときにEditText.requestFocus()を使用していました。それが動作しない場合は、それも試してみてください。 – Lev

+0

これらのメソッドの中では動作しませんなぜ私はgenemotionエミュレータでそれをやっているのか分かりませんが、キーボードは表示されません –

+0

物理デバイスでも一度試してみてください。 –

関連する問題