6 Replies - 834 Views - Last Post: 21 March 2019 - 01:36 PM

#1 markonioni   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-March 19

Search view or dialog with submenus?

Posted 21 March 2019 - 02:25 AM

Hi, I would like to implement functionality when I click on top search toolbar in application, the few buttons appear below search input field, allowing me to select different multi selection sub-menus which are dynamically populated from API, before I submit search. What is the most common way to implement this. What android components should I use. I've tried using dialog for search view container, but I am not sure how to display sub-menu when clicked.

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Search view or dialog with submenus?

#2 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Re: Search view or dialog with submenus?

Posted 21 March 2019 - 10:41 AM

Quote

when I click on top search toolbar in application, the few buttons appear below search input field,


You can use a click event for that then check if control has focus (see below)

Quote

allowing me to select different multi selection sub-menus which are dynamically populated from API,


Xamarin.Forms has data binding capability and I believe android studio does as-well. Preferably you would use a binding context to populate those menus. Otherwise you will likely use a for loop to populate a ListView EDIT or more likely a Spinner based on the return of an API I need more details to be more specific but am glad to help, where I can.


Quote

What is the most common way to implement this. What android components should I use. I've tried using dialog for search view container, but I am not sure how to display sub-menu when clicked.


EditText ListView EDIT: (listview may not be the best, check spinner>>) Spinner and you can control the visibility property for them based on events, focus, or preferably some combination of those and a binding context. You can change the visibility programmatically but usually it's better to do so with the binding context, VM and XML.

VM
visibility

one of the best things about xamarin.forms is the ease of data binding. But if you're in Android studio you might have to do it programmatically. Basically you can change the visibility properties through code or through the XML visibility property.

You could populate listviews And/OR Spinners based on focus of the app:
detect focus

I'm also a bit confused about the question so feel free to elaborate a bit more and post your code for more assistance.

This post has been edited by hexagod: 21 March 2019 - 11:07 AM

Was This Post Helpful? 1
  • +
  • -

#3 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Re: Search view or dialog with submenus?

Posted 21 March 2019 - 10:49 AM

You should do some overall research on data binding but here's a small example of changing a view with data binding on android.

https://stackoverflo...id-data-binding
Was This Post Helpful? 1
  • +
  • -

#4 markonioni   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-March 19

Re: Search view or dialog with submenus?

Posted 21 March 2019 - 12:31 PM

Thanks, I really appreciate it. I am going to try your approach with programatically setting UI components visibility. I think I am gonna set this dynamically populated multi selection list view to have fixed height, say 200dp, and populate it with different data, depending which button is clicked. I am gonna to stack them on top of each other and hide them on back button and Submit button clicks. What do you think?
Was This Post Helpful? 0
  • +
  • -

#5 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Re: Search view or dialog with submenus?

Posted 21 March 2019 - 12:51 PM

EDIT website glitch double post... see below what the heck? :unsure:

This post has been edited by hexagod: 21 March 2019 - 01:10 PM

Was This Post Helpful? 1
  • +
  • -

#6 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Re: Search view or dialog with submenus?

Posted 21 March 2019 - 01:09 PM

That sounds like a good idea to me. If you post some code will make it easier for me to do detailed suggestions. In the long run though you should really look into implementing a binding context for your objects so that the UI will automatically update itself. But yes, stacking buttons and hiding them will definitely work.

Another option would be a case switch inside an onclick event for one single control. You don't have to stack buttons you could do something like this which checks the ViewPager.CurrentItem then invokes different methods within fragments accordingly. is C# done in Xamarin but would be adaptable to Android Studio and might suit your needs.
It checks the fragment when user presses hardware back button (inside MainActivity.cs) then implements the applicable .GoBack() method I've created inside each fragment.

        public override bool onkeydown(Android.Views.Keycode keyCode, KeyEvent e)
        {


            if (e.KeyCode == Android.Views.Keycode.Back)
            {
                switch(_viewPager.CurrentItem)
                {
                    case 0:
                        _fm1.WebViewGoBack();
                        break;
                    case 1:
                        _fm2.WebViewGoBack();
                        break;
                    case 2:
                        _fm3.WebViewGoBack();
                        break;
                    case 3:
                        _fm4.WebViewGoBack();
                        break;
                    case 4:
                        _fm5.WebViewGoBack();
                        break;
                }

            }
            
            return false;
        }

This post has been edited by hexagod: 21 March 2019 - 01:15 PM

Was This Post Helpful? 1
  • +
  • -

#7 hexagod   User is offline

  • 😂😂😂
  • member icon

Reputation: 31
  • View blog
  • Posts: 577
  • Joined: 29-October 16

Re: Search view or dialog with submenus?

Posted 21 March 2019 - 01:36 PM

Sorry that post came off so choppy; I was in the middle of posting, then all my text disappeared; half of what I had typed got posted && I had to re-do the post lol. If you do something like a case switch (Above) you can use a status String or int that gets updated each step that the user is on:

like say they're on the first step of the process, you set stepInt = 1; then the switch knows which method to invoke. Step 2 stepInt = 2 or a String like stepString = "intro" stepString = "addressEntry"

and implements the appropriate method for that step of what they're doing. Then from inside each method you could update an object and either push the changes straight out of the method to UI or even more preferably, you use a binding context to the object (object is updated from methods & UI updates itself automatically).

I know it's a lot to process so just digest slowly and let me know how it goes =]
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1