您的位置:首页 > 产品设计 > UI/UE

xamarin android 主子进程更改UI 与 控制软键盘隐藏

2017-05-22 18:21 344 查看
protected void shoinfo(object sneder, EventArgs e)
{
string userName = FindViewById<EditText>(Resource.Id.userphone).Text;
string pwd = FindViewById<EditText>(Resource.Id.userpwd).Text;
if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(pwd))
{
Toast.MakeText(this, "请输入手机号码和密码", ToastLength.Short).Show();
}
else
{
//隐藏键盘
InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
if (imm != null)
{
imm.HideSoftInputFromWindow(this.Window.DecorView.WindowToken, 0);
}
//loading提示
ProgressDialog progressDialog = ProgressDialog.Show(this, "", "请稍后...");
new Thread(new ThreadStart(() =>
{

string url = this.GetString(Resource.String.url) + "/AppServices/userServices.aspx?action=login";

using (var http = new HttpClient())
{
var content = new FormUrlEncodedContent(new Dictionary<string, string>() {
{ "phone",userName },
{ "pwd",pwd }
});
var response = http.PostAsync(url, content);
string me = response.Result.Content.ReadAsStringAsync().Result;
progressDialog.Dismiss();
this.RunOnUiThread(() =>
{
//子线程显示toast
HandleResult(me);
});
}
})).Start();

}
}
public void HandleResult(string me)
{
Toast.MakeText(this, me, ToastLength.Short).Show();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: