<tfoot id='zWzxe'></tfoot>

      <bdo id='zWzxe'></bdo><ul id='zWzxe'></ul>

      1. <small id='zWzxe'></small><noframes id='zWzxe'>

      2. <i id='zWzxe'><tr id='zWzxe'><dt id='zWzxe'><q id='zWzxe'><span id='zWzxe'><b id='zWzxe'><form id='zWzxe'><ins id='zWzxe'></ins><ul id='zWzxe'></ul><sub id='zWzxe'></sub></form><legend id='zWzxe'></legend><bdo id='zWzxe'><pre id='zWzxe'><center id='zWzxe'></center></pre></bdo></b><th id='zWzxe'></th></span></q></dt></tr></i><div id='zWzxe'><tfoot id='zWzxe'></tfoot><dl id='zWzxe'><fieldset id='zWzxe'></fieldset></dl></div>

      3. <legend id='zWzxe'><style id='zWzxe'><dir id='zWzxe'><q id='zWzxe'></q></dir></style></legend>

        如何使用 setOnPreferenceChangeListener 进行 QuietlyCodi

        时间:2023-08-30
          <tbody id='TfONW'></tbody>

      4. <small id='TfONW'></small><noframes id='TfONW'>

            <i id='TfONW'><tr id='TfONW'><dt id='TfONW'><q id='TfONW'><span id='TfONW'><b id='TfONW'><form id='TfONW'><ins id='TfONW'></ins><ul id='TfONW'></ul><sub id='TfONW'></sub></form><legend id='TfONW'></legend><bdo id='TfONW'><pre id='TfONW'><center id='TfONW'></center></pre></bdo></b><th id='TfONW'></th></span></q></dt></tr></i><div id='TfONW'><tfoot id='TfONW'></tfoot><dl id='TfONW'><fieldset id='TfONW'></fieldset></dl></div>
              • <bdo id='TfONW'></bdo><ul id='TfONW'></ul>
                <legend id='TfONW'><style id='TfONW'><dir id='TfONW'><q id='TfONW'></q></dir></style></legend>
                <tfoot id='TfONW'></tfoot>
                  本文介绍了如何使用 setOnPreferenceChangeListener 进行 QuietlyCoding NumberPicker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想检测 NumberPicker 中的值何时更改.我的 PreferenceActivity 上有这段代码:

                  I want to detect when the value from the NumberPicker is changed. I have this code on my PreferenceActivity:

                  public class MainPrefs extends PreferenceActivity {
                  
                      @Override
                      protected void onCreate(Bundle savedInstanceState) {
                          super.onCreate(savedInstanceState);
                          this.addPreferencesFromResource(R.xml.main_preferences);
                          this.findPreference("SMSSentLimit").setOnPreferenceChangeListener(
                              new OnPreferenceChangeListener() {
                  
                                  @Override
                                  public boolean onPreferenceChange(Preference preference,
                                          Object newValue) {
                                      TrackerService.updateStats(Long.decode(newValue.toString()));
                                      return true;
                                  }
                              });
                          this.findPreference("NumberPickerLimit").setOnPreferenceChangeListener(
                              new Preference.OnPreferenceChangeListener() {
                  
                                  @Override
                                  public boolean onPreferenceChange(Preference preference,
                                          Object newValue) {
                                      Log.i("onPreferenceChange", "NumberPicker Changed");
                                      Toast.makeText(getBaseContext(), "CHANGEEEED !!!",
                                          Toast.LENGTH_SHORT).show();
                                      return true;
                                  }
                              });
                      }
                  }
                  

                  第二个 (findPreference("NumberPickerLimit")) 是 NumberPicker,如果我将其更改为 onPreferenceClickListener,它永远不会被调用它可以工作,但是当我单击首选项而不是更改值时,我会检测到.

                  The second one (findPreference("NumberPickerLimit")) is the NumberPicker and it is never called, if I change it to onPreferenceClickListener it works but I detect when I click the preference instead when I change the value.

                  根据源代码应该是这样调用的:

                  Acording to source code it should be called:

                  public void onClick(DialogInterface dialog, int which) {
                          switch (which) {
                              case DialogInterface.BUTTON_POSITIVE:
                                  saveValue(mPicker.getCurrent());
                                  break;
                              default:
                                  break;
                          }
                      }
                  
                  private void saveValue(int val) {
                      getEditor().putInt(getKey(), val).commit();
                      notifyChanged();
                  }
                  

                  发生了什么事?是bug吗?

                  What´s happening? Is it a bug?

                  编辑这是我的 XML:

                  <com.michaelnovakjr.numberpicker.NumberPickerPreference
                              android:key="NumberPickerLimit"
                              android:title="@string/NumberPickerTitle"
                              android:summary="@string/NumberPickerSummary"
                              picker:defaultValue="1"
                              picker:startRange="1"
                              picker:endRange="31" />
                  

                  推荐答案

                  刚刚查看了您列出的 xml 文件 这里,看起来你有 android:key="demo.preference" 那里.而在此处的代码中,您使用的是 findPreference("NumberPickerLimit").

                  Just looked at your xml file listed here, looks like you have android:key="demo.preference" there. Whereas in the code here, you're using findPreference("NumberPickerLimit").

                  这篇关于如何使用 setOnPreferenceChangeListener 进行 QuietlyCoding NumberPicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:对话框android上的轮子选择器 下一篇:MapView 在对话框中显示较暗的地图

                  相关文章

                  最新文章

                  <small id='CK5oL'></small><noframes id='CK5oL'>

                  • <bdo id='CK5oL'></bdo><ul id='CK5oL'></ul>
                1. <i id='CK5oL'><tr id='CK5oL'><dt id='CK5oL'><q id='CK5oL'><span id='CK5oL'><b id='CK5oL'><form id='CK5oL'><ins id='CK5oL'></ins><ul id='CK5oL'></ul><sub id='CK5oL'></sub></form><legend id='CK5oL'></legend><bdo id='CK5oL'><pre id='CK5oL'><center id='CK5oL'></center></pre></bdo></b><th id='CK5oL'></th></span></q></dt></tr></i><div id='CK5oL'><tfoot id='CK5oL'></tfoot><dl id='CK5oL'><fieldset id='CK5oL'></fieldset></dl></div>
                2. <legend id='CK5oL'><style id='CK5oL'><dir id='CK5oL'><q id='CK5oL'></q></dir></style></legend>

                  <tfoot id='CK5oL'></tfoot>