Reputation: 360
I use SearchableSpinner widget, it is a great spinner, but there is a problem when I want to open the spinner by clicking on a button.
I used performClick()
but instead of showing the searchable dialog, the standard one shows up, the searchable dialog appears only if the user clicks on the spinner, I also tried callOnClick()
and didn't work.
Searchable Dialog:
Standard Spinner:
Upvotes: 3
Views: 1075
Reputation: 7647
Try this:
yourSearchableSpinner.onTouch(view, MotionEvent.obtain(1, 1, MotionEvent.ACTION_UP, 1, 1, 1));
In fragment, you can get view as:
View view;
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
this.view = view;
...
}
In activity, you can get view as:
View view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
view = findViewById(R.id.your_root_view);
...
}
Upvotes: 4