This code log entry is regarding adding Action key to Xamarin.Android soft keyboard. When I tried to do this in one of my project,faced a little problem,So updating here to avoid in future ;( and may helpful to somebody those who are looking for the same.
To Add "search" to softkeyboard.
or Add imeActionOption programmatically,
None : When no action needed
Happiee coding :) Keep visiting.
To Add "search" to softkeyboard.
<EditText android:id="@+id/myEdtTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" android:imeActionId="@+id/ImeSearch" android:imeOptions="actionSearch" android:imeActionLabel="Search" android:textSize="22dp" />
Here we need to mention inputType [where i did mistake]. Mention the text in "imeActionLabel" attribute.
If you want Show only the search symbol instead of text, just remove the
'android:imeActionLabel="Search"'
Lenova tab 7-kitkat |
YU-Lolipop |
or Add imeActionOption programmatically,
txtSearch.SetImeActionLabel ( "Search" , ImeAction.Search );
You can Detect the seach action key pressed using below line of code,
In the same way we can set "Done" action also
You can Detect the seach action key pressed using below line of code,
txtSearch.KeyPress+= delegate(object sender , View.KeyEventArgs e ) { InputMethodManager inputManager = (InputMethodManager)this.GetSystemService (Context.InputMethodService); //Hide softinputwindow inputManager.HideSoftInputFromWindow (this.CurrentFocus.WindowToken, HideSoftInputFlags.NotAlways); if ( e.KeyCode == Keycode.Enter && e.Event.Action == KeyEventActions.Down ) { Console.WriteLine("Search pressed"); } };
In the same way we can set "Done" action also
<EditText android:id="@+id/myEdtTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" android:imeActionId="@+id/imeSearch" android:imeOptions="actionDone" android:textSize="22dp" />
Send : In composed message action etc
None : When no action needed
Happiee coding :) Keep visiting.
No comments:
Post a Comment