私はカレンダー活動を扱っており、データを処理するためのアダプターを実装しています。1 か月の毎日、タグを設定するボタンがあります。ボタンを押すと、タグから日付がわかります。翌月/先月にスキップして、カレンダー ビューのデータを変更することができます。ただし、私の問題は、ボタンのタグを設定するたびに (ビューが再利用されるため)、GRef が増加して解放されず、2000 に達するとアプリがクラッシュすることです。タグを設定するコード行のコメントを外すと、Gref は増加せず、アプリはクラッシュしません。次の方法は、私のアダプターからのものです。
private int key = Resource.Id.string_key;
public override View GetView(int position, View convertView, ViewGroup parent)
{
View row = convertView;
if (row == null)
{
LayoutInflater inflater = (LayoutInflater)_context.GetSystemService(Context.LayoutInflaterService);
row = inflater.Inflate(Resource.Layout.calendar_grid_cell, parent, false);
}
// Get a reference to the Day gridcell
gridcell = (Button)row.FindViewById(Resource.Id.calendar_day_gridcell);
gridcell.SetOnClickListener(this);
string[] words = list[position].Split(delimiterChars);
gridcell.Text = words[2];
gridcell.SetTag(key, words[1]);
return row;
}
私にできることについて誰か提案がありますか?新しいタグを設定する前に、タグ プロパティを null に設定しようとしました。または、タグの使用を避けて他の方法を見つける必要がありますか?