小编ben*_*gen的帖子

如何在我的Mono for Android项目中获取Google提供的Android.Resource.Layout引用

我有一个Mono for Android项目,使用以下代码编译并成功运行.但是,复制/粘贴到我正在处理的新项目中会导致编译器错误,指示:[appnamespace] .Android.Resource.Layout不包含'SimpleListItem2'的定义.

如果我试图访问我定义的xml资源布局,我会发现错误,但我正在尝试访问Google提供的默认资源布局,特别是'SimpleListItem2'.有什么我需要做的让编译器识别默认布局?谢谢!

public override View GetView(int position, View convertView, ViewGroup parent)
{
  View v = convertView;
  if (v == null) {
    LayoutInflater li = (LayoutInflater)this.Context.GetSystemService(Context.LayoutInflaterService);
    v = li.Inflate(Android.Resource.Layout.SimpleListItem2, null);
  }

  TextView tt = (TextView)v.FindViewById(Android.Resource.Id.Text1);
  if (tt != null) { tt.Text = string.Format("{0}, {1}", this.LastName, this.FirstName); }  
  return v;
}
Run Code Online (Sandbox Code Playgroud)

基本上,我正在寻找在Android.Resource.Layout命名空间下的Mono.Android程序集中访问这些布局:

ActivityListItem
BrowserLInkContextHeader
ExpandableListContent
PreferenceCategory
SelectDialogItem
SelectDialogMultiChoice
SelectDialogSingleChoice
SimpleDropDownItem1Line
SimpleExpandableListItem1
SimpleExpandableListItem2
SimpleGalleryItem
SimpleListItem1
SimpleListItem2
SimpleListItemChecked
SimpleListItemMultipleChoice
SimpleListItemSingleChoice
SimpleListItemDropDownItem
SimpleSpinnerItem
TestListItem
TwoLineListItem

c# android xamarin.android

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

标签 统计

android ×1

c# ×1

xamarin.android ×1