public void myIteamClickMethod(object sender, AdapterView.ItemClickEventArgs e) { System.Console.WriteLine("I am clicking on the list item \n\n"); var indexValue = e.Position; //var myValue = movieArray[indexValue]; // System.Console.WriteLine("Value is \n\n " + myValue); string name = myUsersList3[indexValue].name; myDB = new DBHelperclass(this); myDB.deleteitem(name); myUsersList3.RemoveAt(indexValue); float price = 0; //calculating total price of items in list foreach (UserObject myObject in myUsersList3) { // Do something nifty here myDB.InsertValue(myObject.image, myObject.name, "0", myObject.age, "0"); price += float.Parse(myObject.age); } totalprice.Text = "$" + price.ToString("0.00"); MyCustomAdapter myAdapter = new MyCustomAdapter(this, myUsersList3); listView.Adapter = myAdapter; removed_msg.Visibility = Android.Views.ViewStates.Visible; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment View myView = inflater.Inflate(Resource.Layout.FirstTapLayout, container, false); ListView myList = myView.FindViewById <ListView>(Resource.Id.listID); MyCustomAdapter myAdapter = new MyCustomAdapter(myContext, myUsersList); myList.Adapter = myAdapter; myList.ItemClick += myIteamClickMethod; return(myView); //return base.OnCreateView(inflater, container, savedInstanceState); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.orderlist); listView = FindViewById <ListView>(Resource.Id.myListView3); totalprice = FindViewById <TextView>(Resource.Id.price1); removed_msg = FindViewById <TextView>(Resource.Id.removed); removed_msg.Visibility = Android.Views.ViewStates.Gone; //get orderlist data from database myDB = new DBHelperclass(this); myresut3 = myDB.orderList(); var myId1 = 1; var nameValue1 = ""; var emailValue1 = ""; var ageValue1 = ""; var passValue1 = ""; float price = 0; //get cursor values if (myresut3.Count > 0) { while (myresut3.MoveToNext()) { myId1 = myresut3.GetInt(myresut3.GetColumnIndexOrThrow("id")); System.Console.WriteLine("ID from Database: " + myId1); nameValue1 = myresut3.GetString(myresut3.GetColumnIndexOrThrow("names")); System.Console.WriteLine("Name from Database: " + nameValue1); emailValue1 = myresut3.GetString(myresut3.GetColumnIndexOrThrow("email")); System.Console.WriteLine("Email from Database: " + emailValue1); ageValue1 = myresut3.GetString(myresut3.GetColumnIndexOrThrow("age")); System.Console.WriteLine("Age from Database: " + ageValue1); passValue1 = myresut3.GetString(myresut3.GetColumnIndexOrThrow("password")); System.Console.WriteLine("Password from Database: " + passValue1); //adding data in userlist myUsersList3.Add(new UserObject(nameValue1, ageValue1, myId1)); price += float.Parse(ageValue1); } } else { Console.WriteLine("There is data in order list!"); } MyCustomAdapter myAdapter = new MyCustomAdapter(this, myUsersList3); listView.Adapter = myAdapter; totalprice.Text = "$" + price.ToString("0.00"); listView.ItemClick += myIteamClickMethod; /* * myAdapter = new ArrayAdapter * (this, Android.Resource.Layout.SimpleListItem1, movieArray); * myList.Adapter = myAdapter; * myList.ItemClick += myIteamClickMethod; * * mySearch = FindViewById<SearchView>(Resource.Id.searchID); * //Search Events * mySearch.QueryTextChange += mySearchMethod; */ //adding menu in orderlist spinnerView = FindViewById <Spinner>(Resource.Id.spinner1); spinnerView.Adapter = new ArrayAdapter (this, Android.Resource.Layout.SimpleListItem1, myCategory); spinnerView.ItemSelected += MyItemSelectedMethod; }