0

Android 2.2 ではうまく動作する Spinner がありますが、Android 4.2 では動作しません。

仮想アンドロイドでデバッグしようとしましたが、スピナーをクリックすると、デバッグウィンドウで何もせず、仮想アンドロイドがフォーカスを失います。

4

1 に答える 1

1
 Try This-


    Spinner spinnerQuantity;
        spinnerQuantity=(Spinner)findViewById(R.id.spinnerQuantity);
        ArrayAdapter<?> adapterQuantity = new ArrayAdapter<Object>(this, android.R.layout.simple_spinner_item,qtyArray);
                adapterQuantity.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                spinnerQuantity.setAdapter(adapterQuantity);

         spinnerQuantity.setOnItemSelectedListener(new OnItemSelectedListener() {

                    @Override
                    public void onItemSelected(AdapterView<?> parent, View v, int position,long id) {

                        pos=position;
                        System.out.println("selected position:"+pos);
                        if(pos!=0){
                            editItem.setVisibility(View.GONE);
                            spinnerQuantity.setVisibility(View.GONE);
                            textSelectQyt.setVisibility(View.GONE);
                        }
                        else{
                            editItem.setVisibility(View.VISIBLE);
                            spinnerQuantity.setVisibility(View.VISIBLE);
                            textSelectQyt.setVisibility(View.VISIBLE);
                        }
                    }

                    @Override
                    public void onNothingSelected(AdapterView<?> arg0) {
                        // TODO Auto-generated method stub
                        //do nothing
                    }
                });





     And in your xml-




 <Spinner
            android:id="@+id/spinnerQuantity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/text_quantity"
            android:layout_below="@+id/text_quantity"
            android:layout_marginTop="0dp"
            android:prompt="@string/select_quantity" />

    It should work I have tested on all version..
于 2013-07-08T12:21:10.693 に答える