我想在将结果输入OStateUserId对象后运行此语句.
details.Text = OStateUserID.name + "\n" + OStateUserID.population);
bStateuserID.Click += async delegate
{
details.Text=" ";
Guid x = new Guid("33F8A8D5-0DF2-47A0-9C79-002351A95F88");
state OStateUserID =(state) await obj.GetStateByUserId(x.ToString());
details.Text = OStateUserID.name + "\n" + OStateUserID.population);
};
Run Code Online (Sandbox Code Playgroud)
GetStateByUserId()方法返回一个对象class State.
它以异步方式运行.完成操作后,我想将名称和填充分配给TextView详细信息.
我RunOnUIThread()在这种情况下如何使用?
我的便携式类库中有以下代码.但它给出了错误
System.Net.HttpWebRequest不包含的定义GetResponse().
public async Task<object> GetStateByUserId(string userID)
{
HttpWebRequest request;
Stream receiveStream;
StreamReader readStream;
request =(HttpWebRequest)CreateGetWebRequest("state/uid/"+userID);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
receiveStream = response.GetResponseStream ();
readStream = new StreamReader(receiveStream);
string str = readStream.ReadToEnd().ToString();
s = JsonConvert.DeserializeObject<state>(str);
return s;
}
}
Run Code Online (Sandbox Code Playgroud)
谁知道为什么会这样?
我正在使用MvvmCross来创建PCL.在我的Android应用程序中,我创建了一个名为itemc.axml的ItemTemplate的mvx.mvxListView.文件itemc.axml在Layout文件夹中创建,但仍然会出现此错误.错误 - 找不到与给定名称匹配的资源(在'MvxItemTemplate'处,值为'@ layout/itemc')
为什么?
我的FirstView.axml文件如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/constD.Droid"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:text="Show Constituencies"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button1" />
<Mvx.MvxListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
local:MvxBind="ItemsSource Result"
local:MvxItemTemplate="@layout/itemc" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的itemc.axml文件如下.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
local:MvxBind="Text name" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
I have one custom object in my ViewModel.I want to bind only one of its member to textview in my droid view.
Run Code Online (Sandbox Code Playgroud)
我想只绑定该对象的字符串成员到textview目前我正在这样做.
local:MvxBind = "Text Myobject.ItsMember"
Run Code Online (Sandbox Code Playgroud)
好吗?还是我错了?
或者我可以这样做吗?
local:MvxBind = "ItemsSource MyObject ; Text ItsMember"
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
当我的edittext获得焦点时,我想显示软键盘.我写了以下代码来做到这一点.但是,尽管我的edittext正在获得焦点,但仍然没有出现键盘.
private void VerifyCodeEditText_FocusChange(object sender, View.FocusChangeEventArgs e)
{
if(e.HasFocus)
{
var inputManager = (InputMethodManager)GetSystemService(Context.InputMethodService);
inputManager.ShowSoftInput(VerifyCodeEditText, ShowFlags.Implicit);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用MvvmCross创建PCL.我在Command中调用一个方法,通过调用Web服务来获取数据.我想异步执行此数据获取操作.如何在Command中应用异步和等待方法?
有任何想法吗?
我想将流数据从响应流转换为自定义对象.
我想将respose流转换为自定义对象,我正在执行这些步骤.
我的代码如下.
myMethod()
{
state s = new state();
Stream receiveStream;
StreamReader readStream;
HttpWebRequest request;
HttpWebResponse response;
try
{
request = (HttpWebRequest)WebRequest.Create (url);
request.Method = "GET";
request.ContentType = "application/json";
response = (HttpWebResponse)request.GetResponse ();
receiveStream = response.GetResponseStream();
readStream = new StreamReader(receiveStream);
Console.WriteLine (readStream.ReadToEnd());
serializer = new DataContractJsonSerializer(typeof(state));
s = serializer.ReadObject(readStream.BaseStream)as state;
Console.Write(s.name+"\n");
response.Close ();
readStream.Close ();
}
catch (Exception ex)
{
}
}
Run Code Online (Sandbox Code Playgroud)
对象š返回什么.谁能帮我?