Android - How to say someone clicked SPINNER but didn't change the visible item in it

I have a spinner that basically works. If the user selects one of the elements in it, the "onItemSelected" routine notices it simply.

But if the user clicks the same counter, but does not change it to the already visible element that he is currently displaying, the "onItemSelected" routine simply ignores it, and the logs show: -

WARN / InputManagerService (577): the window is already focused, ignoring focus amplification: com.android.internal.view.IInputMethodClient$Stub$Proxy@437948b0

Anyway, will I catch someone who does this? The idea is that my counter contains a list of names, and when the user selects one of the counter, it is added to the list.

I could just add another button to get the name from the counter, but the screen space is already gone and I no longer want to add content.

+3
source share
4 answers

I have never used a counter, but is it possible to reset the position of the spinners in the onItemSelected procedure? To some null value that says "Please select" or something else.

0
source

This problem can be solved by overriding Spinner.onClick(), but this is a bug from Android 3.0 and higher ( Spinner.onClick()called on device 2.2, not called on device 3.0 ).

, AlertDialog.Builder, @adamp.

AlertDialog.Builder builder = new Builder(this);
// maybe get from resources 
CharSequence titles[] = getResources().getTextArray(R.array.titles);
builder.setItems(titles, new DialogInterface.OnClickListener() {
  @Override
  public void onClick(DialogInterface dialog, int which) {
    // add your code here               
  }
});
builder.create().show();
+2

, Spinner, . , Spinner ( "" ?) AlertDialog.Builder. Spinner setSingleChoiceItems, show AlertDialog.Builder, .

+1

setOnItemClickListener? AdapterView.OnItemClickListener mySpinner.setOnItemClickListener, onItemClick

0

Source: https://habr.com/ru/post/1748726/


All Articles