Open SearchableSpinner program programmatically
I am using SearchableSpinner widget, this is a great spinner, but there is a problem where I want to open the spinner by clicking on a button.
I used performClick()
, but instead of showing the searchable dialog box, the standard searchable dialog only appears if the user clicks on the spinner, I also tried it callOnClick()
and didn't work.
Search dialog:
Standard Spinner:
+3
source to share
1 answer
Try the following:
yourSearchableSpinner.onTouch(view, MotionEvent.obtain(1, 1, MotionEvent.ACTION_UP, 1, 1, 1));
In a snippet, you can get the view as:
View view;
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
this.view = view;
...
}
In action, you can get an idea like:
View view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
view = findViewById(R.id.your_root_view);
...
}
+1
source to share