2014-06-19 50 views
1

我想創建微調像actionBar's spinner下拉列表視圖創建微調喜歡在動作條

enter image description here

我已經下文稱以下幾個問題:

  1. How to make spinner like actionbar in native android
  2. ICS spinner outside ActionBar and not working dropdown menu

但在發現我在活動中使用微調器solution.Whenever沒有運氣:

Spinner spinner = (Spinner) findViewById(R.id.spiner_id); 
     ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, 
       R.array.day, android.R.layout.simple_spinner_item); 
     adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
     spinner.setAdapter(adapter); 

以XML:

<Spinner 
     android:id="@+id/spiner_id" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

它給輸出:

enter image description here

我想在下拉視圖中使用微調而不是當前的對話框形式。

PS:在4.2+版本

@Pankaj庫馬爾Thnak您合作,爲快速reply.I在XML中添加android:spinnerMode="dropdown"我的看法微調和它的作品fine.But下拉列表中包含RadioButtons also.How我可以讓它從列表中刪除?

enter image description here

謝謝!

+0

你在'/ res/values/style.xml'中做了什麼改變嗎?如果您創建了一個,請嘗試撤消它並查看更改。 – makata

+0

不,我從來沒有改變我的style.xml中的任何東西。 – Manishika

回答

3

android:spinnerMode="dropdown"添加到Spinner。

<Spinner 
     android:id="@+id/spiner_id" 
     android:layout_width="wrap_content" 
     android:spinnerMode="dropdown" 
     android:layout_height="wrap_content" /> 

而更多的是消除單選按鈕的詳細信息,請閱讀Spinner Button without radio button

+0

謝謝你爲下拉微調工作。我已經編輯了我的問題與輸出m現在。我也想刪除radioButtons。怎麼做? – Manishika

+0

@Manishika查看我添加到答案中的鏈接。這是爲了刪除單選按鈕。 –

+0

感謝它完美:) – Manishika