-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fragment_Tabacco_list.cs
59 lines (49 loc) · 2.01 KB
/
Fragment_Tabacco_list.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Android.OS;
using Android.Views;
using Android.Widget;
using AndroidX.Fragment.App;
using AndroidX.AppCompat.View.Menu;
using System;
using System.Collections.Generic;
namespace ShishaBacon
{
public class Fragment_Tabacco_list : Fragment
{
public EventHandler<TabaccoListEventArgs> itemClicked;
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var view = inflater.Inflate(Resource.Layout.layout_tabacco_list, container, false);
ListView list = view.FindViewById<ListView>(Resource.Id.tl_list);
Spinner spinner = view.FindViewById<Spinner>(Resource.Id.tl_spinner);
var manList = new List<string>();
manList.Add("All");
manList.AddRange(TabaccoList.GetManufactorers());
spinner.Adapter = new ArrayAdapter(Activity, Resource.Layout.sb_listitem, manList);
spinner.ItemSelected += (sender, e) =>
{
list.Adapter = new ArrayAdapter<Tabacco>(Context, Resource.Layout.tl_listitem, TabaccoList.GetFilteredList(spinner.GetItemAtPosition(e.Position).ToString()));
list.Invalidate();
};
list.Adapter = new ArrayAdapter<Tabacco>(Context, Resource.Layout.tl_listitem, TabaccoList.GetList());
list.TextFilterEnabled = true;
list.ItemClick += (sender, e) =>
{
Tabacco tb = TabaccoList.GetItemByString(((TextView)e.View).Text);
itemClicked(this, new TabaccoListEventArgs(tb));
};
return view;
}
}
public class TabaccoListEventArgs : EventArgs
{
public Tabacco Tabacco { get; set; }
public TabaccoListEventArgs(Tabacco tabacco)
{
Tabacco = tabacco;
}
}
}