全部,
我有一个覆盖的 ViewGroup 子类OnCreateDrawableState()
(Xamarin.Android 在 C# 中,所以请原谅 Pascal 套管)。
但是,我对 never 的覆盖OnCreateDrawableState()
会被调用。我试过打电话RefreshDrawableState()
,DrawableStateChanged()
。RequestLayout()
, 和Invalidate()
.
似乎没有任何效果。这是方法:
/// <summary>
/// Handles the create drawable state event by adding in additional states as needed.
/// </summary>
/// <param name="extraSpace">Extra space.</param>
protected override int[] OnCreateDrawableState (int extraSpace)
{
int[] drawableState = base.OnCreateDrawableState(extraSpace + 3);
if (Completed)
{
int[] completedState = new int[] { Resource.Attribute.completed };
MergeDrawableStates(drawableState, completedState);
}
if (Required)
{
int[] requiredState = new int[] { Resource.Attribute.required };
MergeDrawableStates(drawableState, requiredState);
}
if (Valid)
{
int[] validState = new int[] { Resource.Attribute.valid };
MergeDrawableStates(drawableState, validState);
}
Android.Util.Log.Debug("ROW_VIEW", "OnCreateDrawableState Called");
return drawableState;
}
我认为它会正常工作 - 但它永远不会被调用。ViewGroup 本身嵌套在 aListView
和/或 a中LinearLayout
,但似乎没有任何帮助。
这个相关问题没有适合我的答案。