private void InitToolbar()
        {
            try
            {
                var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
                if (toolbar != null)
                {
                    toolbar.Title = "";
                    toolbar.SetTitleTextColor(Color.White);
                    SetSupportActionBar(toolbar);
                    SupportActionBar.SetDisplayShowCustomEnabled(true);
                    SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                    SupportActionBar.SetHomeButtonEnabled(true);
                    SupportActionBar.SetDisplayShowHomeEnabled(true);
                }

                SearchView = FindViewById <AutoCompleteTextView>(Resource.Id.searchBox);
                SearchView.SetOnEditorActionListener(this);
                //SearchView.ClearFocus();

                //Change text colors
                SearchView.SetHintTextColor(Color.Gray);
                SearchView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Beispiel #2
0
        private void InitToolbar()
        {
            try
            {
                Toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
                if (Toolbar != null)
                {
                    Toolbar.Title = " ";
                    Toolbar.SetTitleTextColor(Color.White);
                    SetSupportActionBar(Toolbar);
                    SupportActionBar.SetDisplayShowCustomEnabled(true);
                    SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                    SupportActionBar.SetHomeButtonEnabled(true);
                    SupportActionBar.SetDisplayShowHomeEnabled(true);
                }

                SearchView = FindViewById <AutoCompleteTextView>(Resource.Id.searchBox);
                SearchView.SetOnEditorActionListener(this);
                //SearchView.ClearFocus();

                //Change text colors
                SearchView.SetHintTextColor(Color.ParseColor("#efefef"));
                SearchView.SetTextColor(Color.White);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void InitComponent(View view)
        {
            try
            {
                EmptyStateLayout  = (ViewStub)view.FindViewById(Resource.Id.viewStub);
                TopSongsViewStub  = (ViewStub)view.FindViewById(Resource.Id.viewStubTopSongs);
                TopAlbumsViewStub = (ViewStub)view.FindViewById(Resource.Id.viewStubTopAlbums);

                SwipeRefreshLayout = (SwipeRefreshLayout)view.FindViewById(Resource.Id.swipeRefreshLayout);
                SwipeRefreshLayout.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight);
                SwipeRefreshLayout.Refreshing = true;
                SwipeRefreshLayout.Enabled    = true;
                SwipeRefreshLayout.SetProgressBackgroundColorSchemeColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#424242") : Color.ParseColor("#f7f7f7"));
                SwipeRefreshLayout.Refresh += SwipeRefreshLayoutOnRefresh;

                SearchBox = view.FindViewById <AutoCompleteTextView>(Resource.Id.searchViewBox);
                SearchBox.SetHintTextColor(AppSettings.SetTabDarkTheme ?  Color.White : Color.Gray);
                SearchBox.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Gray);
                SearchBox.Click += SearchBoxOnClick;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void InitToolbar()
        {
            try
            {
                var toolBar = FindViewById <Toolbar>(Resource.Id.toolbar);
                if (toolBar != null)
                {
                    toolBar.Title = "";
                    toolBar.SetTitleTextColor(Color.ParseColor(AppSettings.MainColor));
                    SetSupportActionBar(toolBar);
                    SupportActionBar.SetDisplayShowCustomEnabled(true);
                    SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                    SupportActionBar.SetHomeButtonEnabled(true);
                    SupportActionBar.SetDisplayShowHomeEnabled(true);
                    SupportActionBar.SetHomeAsUpIndicator(AppCompatResources.GetDrawable(this, AppSettings.FlowDirectionRightToLeft ? Resource.Drawable.ic_action_right_arrow_color : Resource.Drawable.ic_action_left_arrow_color));
                }

                SearchView = FindViewById <AutoCompleteTextView>(Resource.Id.searchBox);
                SearchView.SetOnEditorActionListener(this);
                //SearchView.ClearFocus();

                //Change text colors
                SearchView.SetHintTextColor(Color.Gray);
                SearchView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private void showUIControlBasedOnSelection(string intentData)
        {
            Console.WriteLine("on Switch case");
            LinearLayout linearLayoutObject = (LinearLayout)FindViewById(Resource.Id.linearLayout);


            switch (intentData)
            {
            case UI_CONTROLS_IN_ANDROID.textView:
                TextView textView = new TextView(this);
                textView.Text = "Its a sample Text View";
                textView.SetTextColor(Android.Graphics.Color.Red);
                textView.SetBackgroundColor(Android.Graphics.Color.White);
                linearLayoutObject.AddView(textView);
                break;

            case UI_CONTROLS_IN_ANDROID.button:
                Button myButton = new Button(this);
                myButton.Text = "Sample Button";
                linearLayoutObject.AddView(myButton);
                break;

            case UI_CONTROLS_IN_ANDROID.autocompleteTextview:

                AutoCompleteTextView autocompleteTextView = new AutoCompleteTextView(this);
                autocompleteTextView.Text = "Its a sample AutoTextView";
                autocompleteTextView.SetTextColor(Android.Graphics.Color.Red);
                autocompleteTextView.SetBackgroundColor(Android.Graphics.Color.White);
                linearLayoutObject.AddView(autocompleteTextView);

                break;

            case UI_CONTROLS_IN_ANDROID.imageButton:
                ImageButton imageButton = new ImageButton(this);
                imageButton.SetImageResource(Resource.Drawable.mac);
                linearLayoutObject.AddView(imageButton);

                break;

            case UI_CONTROLS_IN_ANDROID.checkbox:
                CheckBox checkBox = new CheckBox(this);
                checkBox.Click += (o, e) =>
                {
                    if (checkBox.Checked)
                    {
                        Toast.MakeText(this, "Selected", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "Not selected", ToastLength.Short).Show();
                    }
                };
                linearLayoutObject.AddView(checkBox);

                break;

            case UI_CONTROLS_IN_ANDROID.toggleButton:
                ToggleButton toggleButton = new ToggleButton(this);
                toggleButton.Click += (o, e) =>
                {
                    // Perform action on clicks
                    if (toggleButton.Checked)
                    {
                        Toast.MakeText(this, "On", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "Off", ToastLength.Short).Show();
                    }
                };
                linearLayoutObject.AddView(toggleButton);
                break;

            case UI_CONTROLS_IN_ANDROID.radioButton:
                RadioButton radioButton = new RadioButton(this);
                radioButton.Text   = "Check the radio button";
                radioButton.Click += (o, e) =>
                {
                    Toast.MakeText(this, radioButton.Text, ToastLength.Short).Show();
                };
                linearLayoutObject.AddView(radioButton);
                break;

            case UI_CONTROLS_IN_ANDROID.radioGroup:

                RadioGroup radioGroup = new RadioGroup(this);

                RadioButton maleRadioButton = new RadioButton(this);
                maleRadioButton.Text   = "Male";
                maleRadioButton.Click += RadioButtonClick;
                radioGroup.AddView(maleRadioButton);

                RadioButton femaleRadioButton = new RadioButton(this);
                femaleRadioButton.Text   = "Female";
                femaleRadioButton.Click += RadioButtonClick;
                radioGroup.AddView(femaleRadioButton);

                RadioButton otherRadioButton = new RadioButton(this);
                otherRadioButton.Text   = "Other";
                otherRadioButton.Click += RadioButtonClick;
                radioGroup.AddView(otherRadioButton);

                linearLayoutObject.AddView(radioGroup);
                break;

            case UI_CONTROLS_IN_ANDROID.progressBar:

                ProgressBar progressBar = new ProgressBar(this);
                progressBar.Max      = 100;
                progressBar.Progress = 30;
                linearLayoutObject.AddView(progressBar);

                break;

            case UI_CONTROLS_IN_ANDROID.spinner:
                Spinner spinner = new Spinner(this);
                spinner.ItemSelected += this.SpinnerItemSelected;

                string[] data = { "Spinner Item 1", "Spinner Item 2", "Spinner Item 3", "Spinner Item 4", "Spinner Item 5" };

                ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerItem, data);
                spinner.Adapter = spinnerArrayAdapter;
                linearLayoutObject.AddView(spinner);

                break;

            case UI_CONTROLS_IN_ANDROID.timePicker:
                TimePicker timePicker = new TimePicker(this);
                timePicker.TimeChanged += (o, e) =>
                {
                    this.onTimeChanged(timePicker, timePicker.Hour, timePicker.Minute);
                };
                linearLayoutObject.AddView(timePicker);
                break;

            case UI_CONTROLS_IN_ANDROID.datePicker:

                DatePicker datePicker = new DatePicker(this);

                datePicker.DateChanged += (o, e) =>
                {
                    Toast.MakeText(this, datePicker.DayOfMonth + " : " + datePicker.Month + " : " + datePicker.Year, ToastLength.Short).Show();
                };

                linearLayoutObject.AddView(datePicker);
                break;

            default:
                break;
            }
        }
Beispiel #6
0
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);

            searchView = Control;
            //linearLayout = Control;

            if (Control != null)
            {
                searchView.Iconified = false;
                searchView.SetIconifiedByDefault(false);
                searchView.BaselineAligned           = false;
                searchView.BaselineAlignedChildIndex = 0;

                /*
                 * linearLayout.RemoveAllViews();
                 * TextView label = new TextView(context);
                 * label.Text = "hola";
                 * linearLayout.AddView(label);
                 * Toolbar toolbar = new Toolbar(context);
                 * toolbar.AddView(new RadioButton(context));
                 * linearLayout.AddView(toolbar);
                 *
                 */

                //searchView.RemoveAllViews();
                //FormsTextView label = new FormsTextView(context);
                //label.Text = "holaaa";
                //searchView.AddView(label);

                // (Resource.Id.search_mag_icon); is wrong / Xammie bug

                //(icon as ImageView).SetImageResource(Resource.Drawable.search);

                //int cancelIconId = Context.Resources.GetIdentifier("android:id/search_close_btn", null, null);
                //var eicon = searchView.FindViewById(cancelIconId);
                //(eicon as ImageView).SetImageResource(Resource.Drawable.search);


                LinearLayout linearLayout = this.Control.GetChildAt(0) as LinearLayout;
                linearLayout = linearLayout.GetChildAt(2) as LinearLayout;
                linearLayout = linearLayout.GetChildAt(1) as LinearLayout;

                linearLayout.Background = null;                                                     //removes underline

                AutoCompleteTextView textView = linearLayout.GetChildAt(0) as AutoCompleteTextView; //modify for text appearance customization

                int searchIconId = Context.Resources.GetIdentifier("android:id/search_mag_icon", null, null);
                icon            = searchView.FindViewById(searchIconId);
                icon.Visibility = ViewStates.Invisible;
                icon.RemoveFromParent();

                var textView2Id = searchView.Context.Resources.GetIdentifier("android:id/search_src_text", null, null);
                var textView2   = (searchView.FindViewById(textView2Id) as EditText);
                if (textView == null)
                {
                    return;
                }
                textView.SetTextColor(global::Android.Graphics.Color.Black);

                IntPtr IntPtrtextViewClass        = JNIEnv.FindClass(typeof(TextView));
                IntPtr mCursorDrawableResProperty = JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I");
                JNIEnv.SetField(Control.Handle, mCursorDrawableResProperty, Resource.Layout.design_layout_tab_text);                 // replace 0 with a Resource.Drawable.my_cursor

                Android.Widget.Button buttonFilter = new Android.Widget.Button(context);
                //buttonFilter.SetBackgroundResource(Resource.Drawable.ic_filter_list_black_24dp);
                //buttonFilter.SetBackgroundColor(Android.Graphics.Color.Transparent);
                //Toolbar toolbar = new Toolbar(context); toolbar = (toolbar.FindViewById(Resource.Layout.Toolbar) as Toolbar);

                //linearLayout.AddView(buttonFilter); <! IMPORTANTE !>

                //var editViewId = searchView.Context.Resources.GetIdentifier("android:id/search_plate", null, null);
                //var editView = (searchView.FindViewById(editViewId) as )

                //LinearLayout linearLayout = this.Control.GetChildAt(0) as LinearLayout;
                //linearLayout = linearLayout.GetChildAt(2) as LinearLayout;
                //linearLayout = linearLayout.GetChildAt(1) as LinearLayout;

                //AutoCompleteTextView textView = linearLayout.GetChildAt(0) as AutoCompleteTextView;
                //textView.SetTextColor(Android.Graphics.Color.Blue);
            }
            if (e.OldElement != null)
            {
            }
            if (e.NewElement != null)
            {
            }

            /*
             * if (e.NewElement == null)
             * {
             *
             *      GradientDrawable gd = new GradientDrawable();
             *      gd.SetStroke(0, Android.Graphics.Color.Transparent);
             *
             *      linearLayout.Background = gd;
             *
             *
             *      textView.SetBackgroundColor(Android.Graphics.Color.Red);
             *
             *      //ImageView icon = linearLayout.GetChildAt(1) as ImageView;
             *      //icon.Visibility = ViewStates.Invisible;
             *
             * }
             */
        }