Java.Lang.Object in Custom ItemViewAdapter for Android lost event handlers when item count is a little big

xi guo 40 Reputation points
2023-09-01T09:40:53.4866667+00:00

I created two Adapter classes inheriting from BaseAdapter, which attempt to eliminate some unnecessary coupling:

  1. SharedItemViewAdapter<TData>: GetView method uses classic form to share views across multiple items;
  2. IsolatedItemViewAdapter<TData>: GetView method is in a radical form, an attempt is made to hold event handlers, if required, for child controls within individual row views. That is, an item corresponds to a unique line view,although there may be significant memory overhead.

Question:

  1. If item count is less than or equal to the threshold(e.g. 5), which depends on how many a screen can hold, the program is OK; otherwize, all event handlers lost, except for the last few at the bottom!
  2. It is no happy with ListView or with GridView when amount is greater than the threshold and there are more errors if we use SharedItemViewAdapter(the row view shared form).

I wonder whether it's garbage collection error action, and how to solve it?

This problem has been bothering me for a long time, and I beg all the gods for help!

Project Source code:

Thanks a lot !

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,378 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,449 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,404 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,106 Reputation points Microsoft External Staff
    2023-09-07T01:27:55.1433333+00:00

    Hello,

    Thanks for your feedback.

    In fact, it seems that Xamarin will be out of being maintained by microsoft after a few months, and it doesn't make much sense to continue the research.

    If you want to continue developing Android native projects through .net. Then you can install the .NET 7.0 SDK and create Android Applications from Visual Studio 2022.

    If you need to migrate from a Xamarin.Android project to .NET 7.0, please refer to Xamarin.Android project migration.

    In dotnet Android applications, you can still refer to the RecyclerView section of the Xamarin documentation for this need.

    Best Regards,

    Alec Liu.


    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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.