我正在尝试设置一个自定义可扩展列表视图适配器(继承自 BaseExpandableListAdapter)以用作 Xamarin.Android 中 ExpandableListView 小部件的适配器。
我正在使用 Visual Studio 2019 和 Xamarin.Android v28.0.0.1
根据这些网站的示例,我得到了一些我认为应该有效的东西。
http://www.appliedcodelog.com/2016/06/expandablelistview-in-xamarin-android.html https://gist.github.com/lprichar/904ade6f1aaf96d172436bed3fb24d9b https://www.codeproject.com/Articles/677206/MonoAndroid-Writing-ExpandableListView-amd
answers_fragment.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ExpandableListView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/answers" />
</LinearLayout>
片段.cs
public class AnswersFragment : Fragment
{
private readonly Dictionary<string, bool> answers;
public AnswersFragment(Dictionary<string, bool> answers)
{
this.answers = answers;
}
// Display list of the questions and where answers matched.
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.Inflate(Resource.Layout.answers_fragment, container, false);
view.FindViewById<ExpandableListView>(Resource.Id.answers).Adapter = new AnswersListViewAdapter(Context, answers); // This is where the implicit type conversion error occurs
return view;
}
}
绝地无双
相关分类