When a View loaded, I want to force SIP to open and show Keyboard with numbers. Also, I want a editText view accepts Letter and Number input from SIP
XML
<EditText android:id="@+id/search_bus_by_num_keyword"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:lines="1" android:layout_weight="1"
android:inputType="numberDecimal"
/>
Code
editTextSearchKeyword = (EditText) context.findViewById(R.id.search_bus_by_num_keyword);
editTextSearchKeyword.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(keyCode == KeyEvent.KEYCODE_ENTER)) {
// Perform action on key press
context.hideSIP(editTextSearchKeyword);
searchRoute();
return true;
}
return false;
}
});
editTextSearchKeyword.setText(searchKeyword);
editTextSearchKeyword.requestFocus();
InputMethodManager mgr = (InputMethodManager) context.getSystemService(context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(editTextSearchKeyword, InputMethodManager.SHOW_FORCED);
When the View loaded:
http://pwong.name/sip_01.png
When I change the SIP from Number to Letter:
http://pwong.name/sip_02.png , I cannot enter Letter to the editText view.
Is it possible to enter both of number and letter for a editText if I set android:inputType=”numberDecimal” to it? Is it possible to change android:inputType at run time?
See this question about how to change the InputType in code. See this link for the EditText input types. As far as your requirements of “I want to force SIP to open and show Keyboard with numbers. Also, I want a editText view accepts Letter and Number input from SIP” – I do not understand. I do not think you can have multiple modes of input for an EditText.