2012-09-06 92 views

回答

1

做這些改變(代碼部分):

public void onClick(View v) 
        { 
         for(RadioButton rb : rButtonList) 
         { 
          if(rb.getId() != position) 
           rb.setChecked(false); 
         } 

         int index = position; 
         String value = entryValues[index].toString(); 
         editor.putString("yourPref", value); 
         editor.commit(); 
         Dialog mDialog = getDialog(); 
         mDialog.dismiss(); 

CustomHolder(View row, int position) 
     {  
      text = (TextView)row.findViewById(R.id.custom_list_view_row_text_view); 
      text.setText(entries[position]); 
     rButton =(RadioButton)row.findViewById(R.id.custom_list_view_row_radio_button); 
      rButton.setId(position); 

      if(entryValues[position].toString().equalsIgnoreCase(FontSize)) 
      { 
       rButton.setChecked(true); 
      } 

if(isChecked) 
        { 
         for(RadioButton rb : rButtonList) 
         { 
          if(rb != buttonView) 
           rb.setChecked(false); 
         } 

         int index = buttonView.getId(); 
         String value = entryValues[index].toString(); 
         editor.putString("yourPref", value); 
         editor.commit(); 

和字號可變填寫構造函數:

SharedPreferences fontsizesetting = PreferenceManager.getDefaultSharedPreferences(context); 
    String temp = fontsizesetting.getString("yourPref","16"); 
+0

嘿,如果我實現它多於一個listPreferences,我怎麼能得到的''鑰匙''在這裏它被硬編碼爲''yourPref「'? – impossible

相關問題