我正在开发Xamarin Android。我已经实现了一个可扩展的回收视图,可以在点击视图时打开(这里是linearLayoutRatingCard)。该卡是单击linearLayoutRatingCard时打开的视图。但我希望回收者视图的第一项在活动开始时打开。我已经通过采取回收器适配器的位置尝试了它,但它没有按照意图工作。这是我的OnBindViewHolder的代码。
int mExpandedPosition = -1;
ViewGroup root;
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
MyRatingViewHolder myholder = (MyRatingViewHolder)holder;
Rating = RatingList[position];
pos = position;
myholder.textViewRatingTitle.Text = Rating.RatingTitle;
bool isExpanded = position == mExpandedPosition;
myholder.card.Visibility = isExpanded ? ViewStates.Visible : ViewStates.Gone;
myholder.linearLayoutRatingCard.Activated = isExpanded;
//if (position == 0)
//{
//myholder.card.Visibility = ViewStates.Visible;
//myholder.linearLayoutRatingCard.Activated = true;
//mExpandedPosition = 0;
//TransitionManager.BeginDelayedTransition(root);
// }
myholder.linearLayoutRatingCard.Click += (sender, e) =>
{
mExpandedPosition = isExpanded ? -1 : position;
TransitionManager.BeginDelayedTransition(root);
NotifyDataSetChanged();
};
myholder.card.Click += (sender, e) =>
{
myholder.card.Visibility = ViewStates.Gone;
};
}
答案 0 :(得分:1)
尝试使用int mExpandedPosition =0
这样,支票的起始位置为0.