public override View GetView(int position, View convertView, ViewGroup parent) { Button btn; if (convertView == null) { // if it's not recycled, initialize some attributes btn = new Button(_context); btn.LayoutParameters = new GridView.LayoutParams((int)convertDpToPixel(140, _context), (int)convertDpToPixel(150, _context)); btn.SetPadding((int)convertDpToPixel(4, _context), (int)convertDpToPixel(20, _context), (int)convertDpToPixel(4, _context), (int)convertDpToPixel(4, _context)); btn.SetTextSize(ComplexUnitType.Sp, 11); btn.SetTextColor(new Color(115, 115, 115)); btn.SetSingleLine(false); btn.Gravity = GravityFlags.Center; btn.Click += (sender, args) => { int pos; int.TryParse(((Button)sender).Tag.ToString(), out pos); if (pos < _displayedDatabases.Count) { _context.OnDatabaseSelected(_displayedDatabases[pos]); } else if (pos < _displayedDatabases.Count + _autoExecItems.Count) { _context.OnAutoExecItemSelected(_autoExecItems[pos - _displayedDatabases.Count]); } else { _context.OnOpenOther(); } }; } else { btn = (Button)convertView; } btn.Tag = position.ToString(); string displayName; Drawable drawable; if (position < _displayedDatabases.Count) { var db = _displayedDatabases[position]; drawable = App.Kp2a.GetResourceDrawable("ic_storage_" + Util.GetProtocolId(db.Ioc)); displayName = db.KpDatabase.Name; displayName += "\n" + App.Kp2a.GetFileStorage(db.Ioc).GetDisplayName(db.Ioc); btn.SetBackgroundResource(Resource.Drawable.storagetype_button_bg); } else if (position < _displayedDatabases.Count + _autoExecItems.Count) { var item = _autoExecItems[position - _displayedDatabases.Count]; drawable = App.Kp2a.GetResourceDrawable("ic_nav_changedb"); displayName = item.Entry.Strings.ReadSafe(PwDefs.TitleField); btn.SetBackgroundResource(Resource.Drawable.storagetype_button_bg_dark); } else { btn.SetBackgroundResource(Resource.Drawable.storagetype_button_bg); displayName = _context.GetString(Resource.String.start_open_file); drawable = App.Kp2a.GetResourceDrawable("ic_nav_changedb"); } var str = new SpannableString(displayName); btn.TextFormatted = str; //var drawable = ContextCompat.GetDrawable(context, Resource.Drawable.Icon); btn.SetCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); return(btn); }