0
私はVisual Studioを使用しています。 ボタンを押したときにforループでi.ToString()のTextViewを更新しようとしていますが、最後の値がの場合、と表示されています。多分私は何かが恋しいです。誰も私が間違って何を説明することはできますか?私はボタンを押した後xamarin update dellayの後のループ内のTextView
namespace MyApp
{
[Activity(MainLauncher = true, NoHistory = true)]
public class MyActivity : Activity
{
public static TextView text1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MyActivity);
}
protected override void OnResume()
{
base.OnResume();
text1 = FindViewById<TextView>(Resource.Id.textView1);
Button btn = FindViewById<Button>(Resource.Id.button1);
btn.Click += delegate
{
for(int i=0; i<5; i++)
{
text1.Text = i.`ToString`();
Task.Delay(1000);
}
};
}
}
}
のTextViewの値は4
P.S.です申し訳ありませんが、私の英語のため
おかげで、それはwork.Iはあなたがいくつかのリンクで私を助けることができる、私は非同期に関するいくつかのドキュメントを読むべきだと思いますか? –
@AlexAlexiucこれを試してみてください:https://msdn.microsoft.com/en-us/library/mt674882.aspx – SushiHangover