Skip to content
This repository has been archived by the owner on Jan 13, 2018. It is now read-only.

Commit

Permalink
Moved Inflater out of GetView.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheesebaron committed Apr 9, 2013
1 parent 5db318d commit dcf1115
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions LegacyBar.Library/BarActions/OverflowLegacyBarAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,38 +115,35 @@ public class OverflowSpinnerAdapter : BaseAdapter
{
private readonly Context _context;
private readonly IEnumerable<string> _items;
private readonly LayoutInflater _inflater;

public OverflowSpinnerAdapter(Context context, IEnumerable<string> items)
{
ResourceIdManager.UpdateIdValues();
_context = context;
_items = items;
_inflater = LayoutInflater.From(_context);
}

public override View GetView(int position, View convertView, ViewGroup parent)
{

if (position < 0)
return null;

View view;
var item = _items.ElementAt(position);

var layoutInflater = LayoutInflater.From(_context);

if (!string.IsNullOrEmpty(item))
view = layoutInflater.Inflate(Resource.Layout.spinneritem, parent, false);
view = _inflater.Inflate(Resource.Layout.spinneritem, parent, false);
else
{
view = layoutInflater.Inflate(Resource.Layout.blankspinner, parent, false);//hack to get first item blank.
view = _inflater.Inflate(Resource.Layout.blankspinner, parent, false);//hack to get first item blank.
return view;
}


if (view == null)
return null;


var itemView = view.FindViewById<CheckedTextView>(Android.Resource.Id.Text1);
itemView.Text = item;

Expand Down

0 comments on commit dcf1115

Please sign in to comment.