public void spinnerSeletion(object sender, AdapterView.ItemSelectedEventArgs e) { var index = e.Position; value = cat[index]; category = value; // if (category != "Mobile"){ var data = realmObj.All <products>(); Userlist = new List <products>(); foreach (var temp in data) { if (temp.Category == category) { var info = new products(); info.Name = temp.Name; info.Desc = temp.Desc; info.Quantity = temp.Quantity; Userlist.Add(info); } } var adapter = new CustomAdapter(contextLocal, Userlist); myList.SetAdapter(adapter); // } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.AddProducts); // Create your application here proname = FindViewById <EditText>(Resource.Id.pname1); proquantity = FindViewById <EditText>(Resource.Id.pquantity1); prodescription = FindViewById <EditText>(Resource.Id.desc1); catagory = FindViewById <EditText>(Resource.Id.catagory1); btn = FindViewById <Button>(Resource.Id.pbtn); var config = new RealmConfiguration() { SchemaVersion = 1 }; add = Realm.GetInstance(config); var Alert = (new AlertDialog.Builder(this)).Create(); btn.Click += delegate { var pname = proname.Text; var pquantity = proquantity.Text; var pdesc = prodescription.Text; var pcat = catagory.Text; var data = new products { Name = pname, Quantity = pquantity, Desc = pdesc, Category = pcat }; if (pname != "" || pquantity != "" || pdesc != "" || pcat != "") { add.Write(() => { add.Add(data); }); Intent back = new Intent(this, typeof(MainActivity)); StartActivity(back); } else { Alert.SetTitle("Alert Dialog"); Alert.SetMessage("Please Fill..!"); Alert.SetButton("OK", (c, ev) => { // Ok button click task }); Alert.Show(); } }; }
private void itemSelectedMethod(object sender, AdapterView.ItemClickEventArgs e) { products productsObj = Userlist[e.Position]; // text = myList.SelectedItem.ToString(); Intent itemDesc = new Intent(contextLocal, typeof(productDetails)); itemDesc.PutExtra("nameValue", userName); itemDesc.PutExtra("myData", productsObj.Name); StartActivity(itemDesc); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { base.OnCreateView(inflater, container, savedInstanceState); var view = inflater.Inflate(Resource.Layout.Item, container, false); var sampleTextView = view.FindViewById <TextView>(Resource.Id.myTxt); var spinner = view.FindViewById <Spinner>(Resource.Id.spin); myList = view.FindViewById <ListView>(Resource.Id.listId); /* var config = new RealmConfiguration() { SchemaVersion = 1 }; * * realmObj = Realm.GetInstance(config); * * var data = realmObj.All<products>(); * * foreach (var temp in data){ * Userlist.Add(temp); * * }*/ //ArrayAdapter myAdapter = new ArrayAdapter(contextLocal, Android.Resource.Layout.SimpleListItem1, Userlist); ArrayAdapter spinAdapter = new ArrayAdapter(contextLocal, Android.Resource.Layout.SimpleListItem1, cat); spinner.Adapter = spinAdapter; spinner.ItemSelected += spinnerSeletion; System.Console.WriteLine("vale is " + category); // myList.ItemClick += itemSelected; // var adapter = new CustomAdapter(contextLocal, Userlist); // myList.SetAdapter(adapter); sampleTextView.Text = "Shop " + myBodyText; myList.ItemClick += itemSelectedMethod; var config = new RealmConfiguration() { SchemaVersion = 1 }; realmObj = Realm.GetInstance(config); realmObj.Refresh(); var data = realmObj.All <products>(); foreach (var temp in data) { if (temp.Category == "Mobile") { var info = new products(); info.Name = temp.Name; info.Desc = temp.Desc; info.Quantity = temp.Quantity; Userlist.Add(info); } } var adapter = new CustomAdapter(contextLocal, Userlist); myList.SetAdapter(adapter); return(view); }