-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemiMainActivity.cs
executable file
·81 lines (59 loc) · 2.5 KB
/
DemiMainActivity.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Support.V7.Widget;
using System.Collections.Generic;
using Android.Support.V7.App;
namespace po4
{
[Activity(Label = "@string/app_name", Theme = "@style/Theme.AppCompat.Light.NoActionBar", MainLauncher = true)]
public class DemiMainActivity : AppCompatActivity
{
RecyclerView mRecyclerView;
RecyclerView.LayoutManager mLayoutManager;
DemiProductListAdapter mAdapter;
DemiProductList mProductList;
Button button;
List<holder> mItems = new List<holder>();
myListViewAdapter adapter;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
mProductList = new DemiProductList();
SetContentView(Resource.Layout.Demiactivity_main);
mRecyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView1);
button = FindViewById<Button>(Resource.Id.button1);
mItems.Add(new holder() { first = "Appel", second = "2 stuks" });
//----------------------------------------------------------------------------------------
// Layout Managing Set-up
mLayoutManager = new GridLayoutManager(this, 2, GridLayoutManager.Vertical, false);
mRecyclerView.SetLayoutManager(mLayoutManager);
//----------------------------------------------------------------------------------------
// Adapter Set-up
mAdapter = new DemiProductListAdapter(mProductList);
mAdapter.ItemClick += OnItemClick;
button.Click += Button_Click;
mRecyclerView.SetAdapter(mAdapter);
}
void OnItemClick(object sender, int position)
{
var intent = new Intent(this, typeof(DemiSecondActivity));
Bundle b = new Bundle();
b.PutInt("CategoryID", (int)mProductList[position].category);
intent.PutExtras(b);
Toast.MakeText(this, "This is in category " + mProductList[position].category, ToastLength.Short).Show();
StartActivity(intent);
}
void Button_Click(object sender, EventArgs e)
{
mItems.Add(new holder() { first = "test", second = "test" });
adapter.NotifyDataSetChanged();
var intent = new Intent(this, typeof(FabioActivity));
StartActivity(intent);
}
}
}