小编sur*_*kla的帖子

错误:只有创建视图层次结构的原始线程才能在Xamarin中触及其视图

我收到了一个错误 error: Only the original thread that created a view hierarchy can touch its views

排队

BookingAdapter expListAdapter = new BookingAdapter (this, listDataHeader,  listDataChild);
try{
explistView.SetAdapter (expListAdapter);
explistView.SetGroupIndicator (null);
}
catch(Exception e) {
Toast.MakeText (this,e+"",ToastLength.Long).Show();
}
Run Code Online (Sandbox Code Playgroud)

这是我的一段代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using System.ServiceModel.Web;
using SalonServices;
using System.ServiceModel;

namespace PariSalon
{
[Activity (Label = "BookingRequest")]           
public class BookingRequest : Activity
{
    public List<GetServices> listDataHeader;
    public …
Run Code Online (Sandbox Code Playgroud)

android xamarin

3
推荐指数
3
解决办法
5298
查看次数

在包含的布局的textview中添加单击侦听器

我有一个布局(MenuLayout),我有一个textView(Logout).我想在该textView中添加一个单击侦听器.我将此布局包含在另一个布局中.

这是代码

<p.FlyOutContainer xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/FlyOutContainer">
<include
    layout="@layout/menuLayout"/>
<include
    layout="@layout/Home" />
Run Code Online (Sandbox Code Playgroud)

我正在为这样的注销编写点击事件的代码

TextView logout = FindViewById<TextView> (Resource.Id.textViewLogout);


        logout.Click += delegate {
            Intent logOut = new Intent(this,typeof(MainActivity));
            StartActivity(logOut);
        };
Run Code Online (Sandbox Code Playgroud)

但是Click事件不起作用.任何人都可以告诉我解决方案我在做错误.

这是我正在使用的源代码链接.

c# android xamarin

2
推荐指数
1
解决办法
5366
查看次数

标签 统计

android ×2

xamarin ×2

c# ×1