Enable a currently disabled Spinner in Android

前端 未结 2 1165
执笔经年
执笔经年 2021-01-24 15:43

I was fooling around with Android and my Java knowledge is limited at best (for instance, I\'m perplexed by the fact that it allows inline classes!?).

My question is as

相关标签:
2条回答
  • 2021-01-24 15:59

    Use the view parameter of onItemSelected to decide which Spinner sent the onItemSelected event. From this doing the logic is simple.

    Make spinner1 2 and 3 member of the class (activity)

    private Spinner spinner1;
    

    Then simply compare the view param against

    if (view==this.spinner1) {
       // event came from spinner 1
       // create a new adapter, assign the new adapter to spinner 2
    } else if (view==this.spinner2) {
       // event came from spinner 2
    }
    
    0 讨论(0)
  • 2021-01-24 16:08

    Try to use this :

        switch(parent.getId())
        {
        case R.id.spinner1:
            Log.d(TAG,"spinner1");
            break;
        case R.id.spinner2:
            Log.d(TAG,"spinner2");
             break;
    
        }
    

    good luck !

    0 讨论(0)
提交回复
热议问题