2012-01-19 81 views
2

我有一個微調,我希望微調提示爲選擇類。因爲我們在android中有android:hint屬性來編輯文本。我不想讓對話框的微調。我希望微調者在下拉選擇之前提示或暗示。可能嗎?? 請幫忙!!!! 謝謝微調提示下拉功能

enter image description here

我曾嘗試下面的代碼,但憑着工作

classname[0] = "SELECT CLASS"; 

    for (int i = 1; i < classdetails.size() + 1; i++) { 

     classname[i] = classdetails.get(i - 1).getClass_name() + " " 
       + classdetails.get(i - 1).getSection_name().toString(); 

    } 

    ArrayAdapter<CharSequence> adapterClasses = new ArrayAdapter<CharSequence>(
      getApplicationContext(), R.layout.spinner_item_class, 
      R.id.spinnerclasstxt, classname); 
    spnrClass.setAdapter(adapterClasses); 
    spnrClass.setSelection(0); 

    spnrClass 
      .setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 

       @Override 
       public void onItemSelected(AdapterView<?> arg0, View arg1, 
         int pos, long arg3) { 

        int selectedindex = pos; 
        if (selectedindex == 0) { 
         spnrSubject.setVisibility(View.INVISIBLE); 
        } else { 
         spnrSubject.setVisibility(View.VISIBLE); 
         selectedClass = classdetails.get(selectedindex - 1); 

         subjectpopulate(selectedClass); 
        } 
       } 

       @Override 
       public void onNothingSelected(AdapterView<?> arg0) { 

       } 

      }); 

回答

1

,你可以爲你的微調這樣的設置提示:

​​

它也可以做到通過xml文件。

android:prompt="@string/prompt_text" 
+6

這適用於對話框型旋鈕,但不適用於下拉類型 –