Beispiel #1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            // LayoutInflater layoutInflater = LayoutInflater.From(context);
            Android.Views.LayoutInflater layoutInflater = ((WarToyActivity)context).LayoutInflater;

            Android.Views.View view = layoutInflater.Inflate(Resource.Layout.Custom3, parent, false);

            TextView tvTitle = view.FindViewById <TextView>(Resource.Id.tvName);

            TextView tvSubTitle = view.FindViewById <TextView>(Resource.Id.tvType);

            TextView tvAge = view.FindViewById <TextView>(Resource.Id.tvAge);

            TextView tvPrice = view.FindViewById <TextView>(Resource.Id.tvPrice);

            ImageView ivProduct = view.FindViewById <ImageView>(Resource.Id.ivProduct);

            Toy temp = objects[position];

            if (temp != null)

            {
                Bitmap bitmap = Helper.Base64ToBitmap(temp.bitmap);
                ivProduct.SetImageBitmap(bitmap);

                tvPrice.Text = "" + temp.GetPrice();

                tvTitle.Text = temp.GetName();

                //  tvSubTitle.Text = temp.GetWeapon();

                tvAge.Text = "" + temp.GetAge();
            }

            return(view);
        }
        public override View GetView(int position, View convertView, ViewGroup parent)//הפעולה שיוצרת את התאים של הרשימה
        {
            Android.Views.LayoutInflater layoutInflater = ((WarToyActivity)context).LayoutInflater;

            Android.Views.View view = layoutInflater.Inflate(Resource.Layout.Custom3, parent, false);//מנפח את התא

            TextView tvTitle = view.FindViewById <TextView>(Resource.Id.tvName);

            TextView tvSubTitle = view.FindViewById <TextView>(Resource.Id.tvType);

            TextView tvAge = view.FindViewById <TextView>(Resource.Id.tvAge);

            TextView tvPrice = view.FindViewById <TextView>(Resource.Id.tvPrice);

            ImageView ivProduct = view.FindViewById <ImageView>(Resource.Id.ivProduct);

            Toy temp = objects[position];//שולף את האיבר במקום הפוסישין

            if (temp != null)

            {
                //אם התנאי מתקיים אז הוא מקבל ומציג את התכונות
                Bitmap bitmap = Helper.Base64ToBitmap(temp.bitmap);
                ivProduct.SetImageBitmap(bitmap);

                tvPrice.Text = "" + temp.GetPrice();

                tvTitle.Text = temp.GetName();



                tvAge.Text = "" + temp.GetAge();
            }

            return(view);//מחזיר התא למקום
        }
Beispiel #3
0
        // public static string dbname = "dbTest10";
        // string path;
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.CartList);
            // CartList = Getalltoys();
            //הצהרה על המשתנים
            lvmylist = FindViewById <ListView>(Resource.Id.lvmylist);
            payment  = FindViewById <TextView>(Resource.Id.payment);
            //קבלת הנתונים מהמסך הקודם
            pic   = Intent.GetStringExtra("pic");
            name  = Intent.GetStringExtra("title");
            price = Intent.GetStringExtra("price");
            age   = Intent.GetStringExtra("age");
            j     = int.Parse(price);
            k     = int.Parse(age);
            t     = new Toy("", name, j, "", k);

            /* path = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), dbname);
             * var db = new SQLiteConnection(path);//create db object
             * db.CreateTable<Toy>();*/

            var db = new SQLiteConnection(Helper.Path());

            db.CreateTable <Toy>();                              //יצירת הטבלה
            db.Insert(t);                                        //הוספת השורה לטבלה

            string strsql = string.Format("SELECT * FROM toys"); //בוחר מתוך הטבלה את כל השורות
            var    ptrs   = db.Query <Toy>(strsql);

            CartList = new List <Toy>();
            if (ptrs.Count > 0)
            {
                foreach (var item in ptrs)
                {
                    CartList.Add(item);//מוסיף לרשימה
                }

                // lvmklist = Getalltoys();
                listadapter      = new CartAdapter(this, CartList);
                lvmylist.Adapter = listadapter;
                lvmylist.OnItemLongClickListener = this;
                //חיבור המחירים של כל המוצרים ששמורים בטבלה
                for (int i = 0; i < CartList.Count; i++)
                {
                    h += CartList[i].GetPrice();
                }
                payment.Text = h.ToString();
                //username = Intent.GetStringExtra("username");
            }

            /*public List<Toy> Getalltoys()
             * {//מראה את כל הרשימה ששמורה בטבלה
             *  var db = new SQLiteConnection(Helper.Path());
             *  string strsql = string.Format("SELECT * FROM toys");//בוחר מתוך הטבלה את כל השורות
             *  var ptrs = db.Query<Toy>(strsql);
             *  lvmklist = new List<Toy>();
             *  if (ptrs.Count > 0)
             *  {
             *      foreach (var item in ptrs)
             *      {
             *          lvmklist.Add(item);//מוסיף לרשימה
             *      }
             *  }
             *///return lvmklist;//מציג את הרשימה
        }