Hello.
I've made a ListView with custom Adapter and ListItem, but event "ItemClick"
is not working.
internal class ShellListAdapter:BaseAdapter<Shell>
{
private Activity _context;
private List<Shell> _items;
private OnShellItemClick _handler;
/// <summary>
/// Initializes a new instance of the <see
cref="ClientWorkerAndroid.ShellListAdapter"/> class.
/// </summary>
///
/// Context. Текущая activity
///
///
/// Items. Список объектов
///
///
/// Listener. Обработчик клика на элемент
///
public ShellListAdapter (Activity context, List<Shell> items,
OnShellItemClick listener): base()
{
_items = items;
_context = context;
_handler = listener;
}
public override long GetItemId (int position)
{
return position;
}
public override Shell this [int position] {
get { return _items [position]; }
}
public override Java.Lang.Object GetItem (int position)
{
return position;
}
public override int Count {
get { return _items.Count; }
}
public override View GetView (int position, View convertView, ViewGroup
parent)
{
var item = _items [position];
View view = convertView;
if (view == null)
view = _context.LayoutInflater.Inflate
(Resource.Layout.ListShellsItem,
null);
view.FindViewById<TextView> (Resource.Id.ShellId).Text =
item.id;
view.FindViewById<ImageView>
(Resource.Id.ShellIcon).SetImageResource
(item.icon);
//Ужасный костыль :(
view.Click -= ItemClickHandler;
view.Click += ItemClickHandler;
return view;
}
public Shell GetItemAtPosition (int position)
{
return _items [position];
}
public Shell GetItemByShellId (string shellId)
{
var sItem = _items.Find (value => value.id == shellId);
if(sItem==null)
return null;
return sItem;
}
private void ItemClickHandler (object sender, EventArgs e)
{
var view = sender as LinearLayout;
_handler (view.FindViewById<TextView>
(Resource.Id.ShellId).Text);
}
}
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/ListViewItem-selection-tp5711677.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid