Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to automatically open soft keyboard on app startup
    primarykey
    data
    text
    <p>I am a begginer on Java and Android dev.</p> <p>As you launch Google Search, the Soft Keyboard immediatly appears.</p> <p>I'm trying to do the same. I searched a lot and i see that there are many different ways to obtain this, the problem is that none of them seems to work</p> <p><strong>requestFocus()</strong></p> <p>in my Activity i tried to </p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); searchEditText = (EditText) findViewById(R.id.search_edit_text); searchEditText.requestFocus(); }); </code></pre> <p><strong>requestFocus (xml)</strong></p> <p>in my xml layout file i tried to</p> <pre><code> &lt;EditText android:id="@+id/search_edit_text" android:hint="@string/search" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="text" android:imeOptions="actionSend" android:singleLine="true"&gt; &lt;requestFocus /&gt; &lt;/EditText&gt; </code></pre> <p><strong>manifest</strong></p> <p>in the manifest xml I tried</p> <pre><code>android:windowSoftInputMode="stateAlwaysVisible" </code></pre> <p>and</p> <pre><code>android:windowSoftInputMode="stateVisible" </code></pre> <p><strong>InputMethodManager</strong></p> <p>in the Activity I tried</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); searchEditText = (EditText) findViewById(R.id.search_edit_text); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(searchEditText, InputMethodManager.SHOW_IMPLICIT); }); </code></pre> <p><strong>Runnable</strong></p> <p>in my Activity</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); searchEditText = (EditText) findViewById(R.id.search_edit_text); searchEditText.requestFocus(); searchEditText.postDelayed(new Runnable() { @Override public void run() { InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.showSoftInput(searchEditText, 0); } },200);; }); </code></pre> <p>As I said in the begging, I'm sure it could work, cause it works on Google Search.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload