In my app, when the user is editting a certain MultiAutoCompleteTextView with a virtual keyboard, I want to present him the default android keyboard, but change two of the buttons on it - not their locations, but the drawings on them (the voice input and the smiley buttons), and their functionality. is there a way of doing开发者_Python百科 so without creating a new InputMethod or a new keyboard class?
Well you can certainly create a custom soft keyboard, But I think you should live with what you have in you scenario. To create a new keyboard input for such a small requirement will really be an overhead to your project cost.
Check out SDK Sample for SoftKeyboard for more information on creating that. You can always define you action key to be smiley button.
Heres a code sample directly from android open source project:
<EditText
android:id="@+id/embedded_text_editor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoText="true"
android:capitalize="sentences"
android:maxLines="4"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:imeOptions="actionSend|flagNoEnterAction"
android:maxLength="1000"
/>
note the android:inputType="textShortMessage"
which is doing the trick and creating a smiley button as the action button.
精彩评论