C# 图像按钮未显示在listview中

C# 图像按钮未显示在listview中,c#,android,listview,xamarin,C#,Android,Listview,Xamarin,我正在尝试在我的listview中的行上获取删除按钮。但是,在设计器中,按钮正在显示,但在调试或运行应用程序时,我看不到它。这是我的密码 适配器: using System.Collections.Generic; using Android.App; using Android.Graphics; using Android.Views; using Android.Widget; using CardAppReal.Lib.Models; using Square.Picasso; nam

我正在尝试在我的listview中的行上获取删除按钮。但是,在设计器中,按钮正在显示,但在调试或运行应用程序时,我看不到它。这是我的密码

适配器:

using System.Collections.Generic;
using Android.App;
using Android.Graphics;
using Android.Views;
using Android.Widget;
using CardAppReal.Lib.Models;
using Square.Picasso;

namespace CardAppReal.Assets
{
    public class ListAdapter : BaseAdapter<Card>
    {
        List<Card> items;
        Activity context;
        public ListAdapter(Activity context, List<Card> items)
            : base()
        {
            this.context = context;
            this.items = items;
        }
        public override long GetItemId(int position)
        {
            return position;
        }
        public override Card this[int position]
        {
            get { return items[position]; }
        }
        public override int Count
        {
            get { return items.Count; }
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var item = items[position];
            View view = convertView;
            if (view == null) // no view to re-use, create new
                view = context.LayoutInflater.Inflate(NavigationDrawerTest.Resource.Layout.CardSavedRowLayout, null);
            view.FindViewById<TextView>(NavigationDrawerTest.Resource.Id.TextCardSavedList1).Text = item.name;
            view.FindViewById<TextView>(NavigationDrawerTest.Resource.Id.TextCardSavedList2).Text = item.supertype;
            view.FindViewById<TextView>(NavigationDrawerTest.Resource.Id.TextCardSavedList3).Text = item.set;
            Picasso.With(context).Load(item.imageUrl).Into(view.FindViewById<ImageView>(NavigationDrawerTest.Resource.Id.CardSavedImage));
            var imgButton = view.FindViewById<ImageButton>(NavigationDrawerTest.Resource.Id.ImgButtonSaved);
            view.SetBackgroundColor(Color.Argb(150, 153, 217, 234));
            return view;
        }
    }
}
使用System.Collections.Generic;
使用Android.App;
使用Android.Graphics;
使用Android.Views;
使用Android.Widget;
使用CardAppReal.Lib.Models;
使用正方形。毕加索;
名称空间CardAppReal.Assets
{
公共类ListAdapter:BaseAdapter
{
清单项目;
活动语境;
公共ListAdapter(活动上下文、列表项)
:base()
{
this.context=上下文;
这个项目=项目;
}
公共覆盖长GetItemId(int位置)
{
返回位置;
}
公共覆盖卡此[int位置]
{
获取{返回项目[位置];}
}
公共覆盖整数计数
{
获取{return items.Count;}
}
公共覆盖视图GetView(int位置、视图转换视图、视图组父视图)
{
var项目=项目[位置];
视图=转换视图;
如果(view==null)//没有要重用的视图,则创建新的
视图=context.LayoutInflater.flate(导航抽屉test.Resource.Layout.CardSavedRowLayout,null);
view.FindViewById(NavigationDroperTest.Resource.Id.TextCardSavedList1).Text=item.name;
view.FindViewById(NavigationDroperTest.Resource.Id.TextCardSavedList2).Text=item.supertype;
view.FindViewById(NavigationDroperTest.Resource.Id.TextCardSavedList3).Text=item.set;
Picasso.With(context).Load(item.imageUrl).Into(view.findviewbyd(NavigationDrawerTest.Resource.Id.CardSavedImage));
var imgButton=view.findviewbyd(NavigationDrawerTest.Resource.Id.ImgButtonSaved);
视图.SetBackgroundColor(Color.Argb(150153217234));
返回视图;
}
}
}
xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#FFDAFF7F"
    android:padding="8dp">
    <ImageButton
        android:id="@+id/ImgButtonSaved"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:src="@drawable/delete"
        android:layout_alignParentLeft="true"
        android:gravity="center" />
    <LinearLayout
        android:id="@+id/TextCardList"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="10dip">
        <TextView
            android:id="@+id/TextCardSavedList1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#FF7F3300"
            android:textSize="20dip"
            android:textStyle="italic" />
        <TextView
            android:id="@+id/TextCardSavedList2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14dip"
            android:textColor="#FF267F00"
            android:paddingLeft="5dip" />
        <TextView
            android:id="@+id/TextCardSavedList3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14dip"
            android:textColor="#FF267F00"
            android:paddingLeft="5dip" />
    </LinearLayout>
    <ImageView
        android:id="@+id/CardSavedImage"
        android:layout_width="100dp"
        android:layout_height="150dp"
        android:padding="10dp"
        android:src="@drawable/icon"
        android:layout_alignParentRight="true" />
</RelativeLayout>


尝试了几件事,但都没有表现出来。ImageView正常显示,与预期的一样。我不知道我会错在哪里。我想它在我的适配器中,我需要做更多的事情,然后简单地声明imgbutton。但我不知道我还需要做些什么。

经过几个小时的观察,我终于意识到我使用了错误的适配器。。。这是对开发时间的极大浪费。我希望当其他人阅读本文时,他们会仔细检查他们正在使用的适配器


谢谢你的关注

我假设您的
线性布局与
按钮重叠。在您的
线性布局中添加一个
android:layout_-toRightOf=“@+id/ImgButtonSaved”
,看看是否有帮助。@amylin没有帮助。谢谢你!作为提示,请检查默认图像的imageview并删除“使用毕加索”,可能您会发现问题所在。@nitipatel图像视图工作正常。不显示的是imagebutton。