Hello,
Welcome to our Microsoft Q&A platform!
Could you change the sequence of the List<String> when you display the RecycleView
? If so, we can get the longest string in the List
, then switch the place between longest string and the first item in the List<String>
. then we set the datasource for RecycleView
.
Here is code
List<string> strs = new List<string>();
//add some strings strs.Add("No Par");
//get the longest item index
int MaxTextIndex = 0;
for (int i = 1; i < strs.Count; i++)
{
if (strs[i ].Length > strs[MaxTextIndex].Length)
{
MaxTextIndex = i;
}
}
//switch the index.
string longestStr = strs[MaxTextIndex];
string FirstStr = strs[0];
strs[0] = longestStr;
strs[MaxTextIndex] = FirstStr;
RecyclerView mRecyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
mRecyclerView.SetLayoutManager(linearLayoutManager);
MyRecycleViewAdapter recycleViewAdapter = new MyRecycleViewAdapter(this, strs);
mRecyclerView.SetAdapter(recycleViewAdapter);
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.