raj*_*aji 5 c# android xamarin.android android-softkeyboard
我正在研究Xamarin(Android).现在我想在外面点击后隐藏键盘Edit Text.
提前致谢.
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
RequestWindowFeature(WindowFeatures.NoTitle);
SetContentView(Resource.Layout.Main);
EditText Etusername= FindViewById<EditText>(Resource.Id.EtUname);
Etusername.SetHintTextColor(Color.Gray);
InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
imm.HideSoftInputFromWindow(Etusername.WindowToken, 0);
}
Run Code Online (Sandbox Code Playgroud)
使用此代码隐藏Keyboard.
public override bool OnTouchEvent(MotionEvent e)
{
InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
imm.HideSoftInputFromWindow(Etusername.WindowToken, 0);
return base.OnTouchEvent(e);
}
Run Code Online (Sandbox Code Playgroud)
并确保您必须添加此库:
using Android.Views.InputMethods;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9783 次 |
| 最近记录: |