如果您需要更多详细信息,请先评论第一个问题。
我现在和Xamarin一起工作了几个月,我遇到了这个问题,我无法继承System.Int32[][]
。我和Joe Rock一起观看了一些视频,但现在我已经遇到了这个问题。
我有使用Android.App; 和必要的参考。
它只是一个新的空类。另一件事是,当我输入
时,intellisense没有响应代码
DialogFragment
答案 0 :(得分:1)
您应该覆盖OnCreateDialog
并指定您对新自定义列表的实际操作。
可能的解决方案可能如下所示
using System.Collections.Generic;
using System.Linq;
using Android.App;
using Android.OS;
using SupportDialogFragment = Android.Support.V4.App.DialogFragment;
namespace Example.Android.App.Views.Base
{
public class ListDialogFragment : SupportDialogFragment
{
public static readonly string TAG = "LIST_DIALOG";
string _title;
IList<string> _items;
public static ListDialogFragment NewInstance(IList<string> items, string title)
{
ListDialogFragment frag = new ListDialogFragment();
frag._items = items;
frag._title = title;
return frag;
}
public override Dialog OnCreateDialog(Bundle savedInstanceState)
{
AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
builder.SetTitle(_title)
.SetItems(_items.ToArray(), (sender, e) => { /* implement your item click listener here */ })
.SetCancelable(true)
.SetNegativeButton("Cancel", (sender, e) => { /* implement your Cancel button click listener here */ });
return builder.Create();
}
}
}
请勿忘记从您的活动中正确调用
List<string> items = new List<string>();
// Add list items
ListDialogFragment frag = ListDialogFragment.NewInstance(items, "List title");
frag.Show(SupportFragmentManager, ListDialogFragment.TAG);
https://gist.github.com/olegflo/0fae549dd31ab1e21a36fcd73e8967de