我创建了一个看起来像这样的简单Renderer
using Android.Runtime;
using Android.Widget;
using Example.Pages.MaterialPages;
using Example.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(MaterialsListView), typeof(MaterialsListViewRenderer))]
namespace Example.Droid.Renderers
{
public class MaterialsListViewRenderer : ListViewRenderer
{
public MaterialsListViewRenderer() {}
}
internal class ScrollListener : Java.Lang.Object, AbsListView.IOnScrollListener
{
public void OnScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { }
public void OnScrollStateChanged(AbsListView view, [GeneratedEnum] ScrollState scrollState)
{
if (scrollState == ScrollState.TouchScroll)
{
// GET THE CURRENT FOCUSED ELEMENT
}
}
}
}
现在我需要在Java中获得当前焦点,如getCurrentFocus
。
但是我怎么能在Xamarin中做到这一点?
答案 0 :(得分:1)
您需要将Context
的{{1}}转换为ListView
。
Activity