예제 #1
0
        public Android.Views.View GetView(Com.Syncfusion.Autocomplete.SfAutoComplete autoComplete, string text, int index)
        {
            GC.Collect();
            LinearLayout linearLayout = new LinearLayout(autoComplete.Context);

            linearLayout.SetPadding((int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()));
            linearLayout.LayoutParameters = new ViewGroup.LayoutParams(autoComplete.LayoutParameters.Width, autoComplete.LayoutParameters.Height);
            linearLayout.Orientation      = Orientation.Horizontal;
            TextView imageView = new TextView(autoComplete.Context);
            Typeface tf        = Typeface.CreateFromAsset(autoComplete.Context.Assets, "icon.ttf");

            imageView.Text = "A";
            imageView.SetPadding((int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()), 0);
            imageView.Typeface      = tf;
            imageView.TextSize      = 18;
            imageView.Gravity       = GravityFlags.Center;
            imageView.TextAlignment = TextAlignment.Center;

            TextView textView = new TextView(autoComplete.Context);

            textView.SetPadding((int)(3 * autoComplete.GetDensity()), 0, 0, 0);
            textView.Text          = text;
            textView.TextSize      = 18;
            textView.Gravity       = GravityFlags.Center;
            textView.TextAlignment = TextAlignment.Center;

            linearLayout.AddView(imageView);
            linearLayout.AddView(textView);

            return(linearLayout);
        }
        public Android.Views.View GetView(Com.Syncfusion.Autocomplete.SfAutoComplete autoComplete, string text, int index)
        {
            GC.Collect();
            string contactTypeValue = "", contactImageValue = "", contactNameValue = "", contactNumberValue = "";

            var contactType = autoComplete.DataSource.ElementAt(index);

            foreach (var property in contactType.GetType().GetProperties())
            {
                if (property.Name.Equals("ContactType"))
                {
                    contactTypeValue = (property.GetValue(contactType).ToString().ToLower());
                    contactTypeValue = contactTypeValue.Split('.')[0];
                }
                else if (property.Name.Equals("ContactImage"))
                {
                    contactImageValue = (property.GetValue(contactType).ToString().ToLower());
                    contactImageValue = contactImageValue.Split('.')[0];
                }
                else if (property.Name.Equals("ContactName"))
                {
                    contactNameValue = (property.GetValue(contactType).ToString());
                }
                else if (property.Name.Equals("ContactNumber"))
                {
                    contactNumberValue = (property.GetValue(contactType).ToString());
                }
            }

            ImageView contactTypeImage = new ImageView(autoComplete.Context);

            contactTypeImage.SetImageResource(autoComplete.GetImageResId(contactTypeValue));
            LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams((int)(40 * autoComplete.GetDensity()), (int)(40 * autoComplete.GetDensity()));
            contactTypeImage.LayoutParameters = parms;

            ImageView contactImageImage = new ImageView(autoComplete.Context);

            contactImageImage.SetImageResource(autoComplete.GetImageResId(contactImageValue));
            LinearLayout.LayoutParams parms12 = new LinearLayout.LayoutParams((int)(40 * autoComplete.GetDensity()), (int)(40 * autoComplete.GetDensity()));
            contactImageImage.LayoutParameters = parms12;

            FrameLayout frameLayout = new FrameLayout(autoComplete.Context);

            frameLayout.SetPadding((int)(10 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()), 0, 0);
            FrameLayout.LayoutParams parmsFrame = new FrameLayout.LayoutParams((int)(50 * autoComplete.GetDensity()), (int)(43 * autoComplete.GetDensity()));
            frameLayout.LayoutParameters = parmsFrame;
            //frameLayout.AddView(contactTypeImage);
            frameLayout.AddView(contactImageImage);


            TextView nameText = new TextView(autoComplete.Context);

            nameText.Text     = contactNameValue;
            nameText.TextSize = 16;

            TextView emailText = new TextView(autoComplete.Context);

            emailText.Text     = contactNumberValue;
            emailText.TextSize = 12;

            LinearLayout textLayout = new LinearLayout(autoComplete.Context);

            textLayout.SetPadding((int)(10 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()));
            textLayout.LayoutParameters = new ViewGroup.LayoutParams(autoComplete.LayoutParameters.Width, autoComplete.LayoutParameters.Height);
            textLayout.Orientation      = Android.Widget.Orientation.Vertical;
            textLayout.AddView(nameText);
            textLayout.AddView(emailText);

            LinearLayout linearLayout = new LinearLayout(autoComplete.Context);

            linearLayout.SetPadding((int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()), (int)(3 * autoComplete.GetDensity()));
            linearLayout.LayoutParameters = new ViewGroup.LayoutParams(autoComplete.LayoutParameters.Width, autoComplete.LayoutParameters.Height);
            linearLayout.Orientation      = Android.Widget.Orientation.Horizontal;
            linearLayout.AddView(frameLayout);
            linearLayout.AddView(textLayout);
            linearLayout.SetGravity(GravityFlags.CenterVertical);

            return(linearLayout);
        }