/
DemiThirdActivity.cs
63 lines (51 loc) · 2.23 KB
/
DemiThirdActivity.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
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;
using System.Linq;
namespace po4
{
[Activity(Label = "@string/app_name", Theme = "@style/Theme.AppCompat.Light.NoActionBar", MainLauncher = false)]
public class DemiThirdActivity : AppCompatActivity
{
RecyclerView mRecyclerView;
RecyclerView.LayoutManager mLayoutManager;
DemiProductAdapter mAdapter;
DemiProductList mProductList;
DemiProductCategory CategoryID;
DemiProductGroup GroupID;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Demiactivity_main);
mRecyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView1);
if (this.Intent.Extras != null)
{
var category = (DemiProductCategory) Intent.Extras.GetInt("CategoryID");
var group = (DemiProductGroup) Intent.Extras.GetInt("GroupID");
CategoryID = category;
GroupID = group;
}
mProductList = new DemiProductList(CategoryID, GroupID);
//----------------------------------------------------------------------------------------
// Layout Managing Set-up
mLayoutManager = new GridLayoutManager(this, 2, GridLayoutManager.Vertical, false);
mRecyclerView.SetLayoutManager(mLayoutManager);
//----------------------------------------------------------------------------------------
// Adapter Set-up
mAdapter = new DemiProductAdapter(mProductList);
mAdapter.ItemClick += OnItemClick;
mRecyclerView.SetAdapter(mAdapter);
}
void OnItemClick(object sender, int position)
{
Toast.MakeText(this, "This is product " + mProductList[position].name, ToastLength.Short).Show();
}
}
}