2017-02-11 8 views
-1

私はスピナーアイテムのサイズを増やそうとしています。私はすべてのスピナー項目を宣言したSPINNERVALUESという配列をとりました。私はそれらをXMLファイルに宣言しました。これが問題になるかもしれません。スピナーアイテムのサイズとスピナードロップボックスの高さを変更するにはどうすればよいですか?

public class spinner extends AppCompatActivity { 

Spinner spinner; 
String[] SPINNERVALUES = {"BVP","SINGHAD","MIT"}; 
String SpinnerValue; 
Button GOTO; 
Intent intent; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_spinner); 



     spinner =(Spinner)findViewById(R.id.spinner1); 

     GOTO = (Button)findViewById(R.id.button1); 

     ArrayAdapter<String> adapter = new ArrayAdapter<String>(spinner.this,android.R.layout.simple_list_item_1,SPINNERVALUES); 

     spinner.setAdapter(adapter); 

     //Adding setOnItemSelectedListener method on spinner. 
     spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 

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

       SpinnerValue = (String)spinner.getSelectedItem(); 
      } 

      @Override 
      public void onNothingSelected(AdapterView<?> parent) { 
       // TODO Auto-generated method stub 

      } 
     }); 

     GOTO.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       // TODO Auto-generated method stub 

       switch(SpinnerValue) { 

        case "BVP": 
         intent = new Intent(spinner.this, CoverActivity.class); 
         startActivity(intent); 
         break; 

        case "SINGHAD": 
         intent = new Intent(spinner.this, CoverActivity.class); 
         startActivity(intent); 
         break; 

        case "MIT": 
         intent = new Intent(spinner.this, CoverActivity.class); 
         startActivity(intent); 
         break; 
       } 
      } 
     }); 

    } 

と私のxmlファイル

<Spinner 
    android:id="@+id/spinner1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="60dp" 
    android:layout_below="@+id/textView" 
    android:layout_centerHorizontal="true" /> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="SUBMIT" 
    android:textStyle="bold" 
    android:background="#3F51B5" 
    android:textSize="20dp" 
    android:layout_below="@+id/spinner1" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="81dp" /> 
+0

「スピナーアイテムのサイズを大きくする」とはどういう意味ですか?スピナーで – tahsinRupam

+0

アイテムを詳しく説明してください –

+0

String [] SPINNERVALUES = {"BVP"、 "SINGHAD"、 "MIT"}; –

答えて

0

このコードを追加している:あなたの次のコード(アダプタを設定する)前に

adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 

spinner.setAdapter(adapter); 

はあなたを修正あなたの希望でドロップダウンアイテムを - "simple_spinner_d ropdown_item.xml "と入力します。 サンプル: -

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="4dp" 
    android:textSize="14sp" 
    android:typeface="serif" 
    android:singleLine="true" 
    android:layout_marginLeft="2dip" 
    android:layout_marginRight="5dip" 
    android:ellipsize="marquee" 
    android:textColor="#000000"> 
</TextView> 

希望します。 :)

+0

おかげで...それは働いた –

+0

あなたは大歓迎です。それが役に立ったら、私の答えを受け入れたものとしてマークしてください。 :) – tahsinRupam

関連する問題