久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='v2Qeg'></tfoot>
    • <bdo id='v2Qeg'></bdo><ul id='v2Qeg'></ul>

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

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

        帶有數(shù)字選擇器的 Android PreferenceActivity 對話框

        Android PreferenceActivity dialog with number picker(帶有數(shù)字選擇器的 Android PreferenceActivity 對話框)

          <i id='L9MXa'><tr id='L9MXa'><dt id='L9MXa'><q id='L9MXa'><span id='L9MXa'><b id='L9MXa'><form id='L9MXa'><ins id='L9MXa'></ins><ul id='L9MXa'></ul><sub id='L9MXa'></sub></form><legend id='L9MXa'></legend><bdo id='L9MXa'><pre id='L9MXa'><center id='L9MXa'></center></pre></bdo></b><th id='L9MXa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='L9MXa'><tfoot id='L9MXa'></tfoot><dl id='L9MXa'><fieldset id='L9MXa'></fieldset></dl></div>

          1. <tfoot id='L9MXa'></tfoot>
              <tbody id='L9MXa'></tbody>
            <legend id='L9MXa'><style id='L9MXa'><dir id='L9MXa'><q id='L9MXa'></q></dir></style></legend>

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

                • <bdo id='L9MXa'></bdo><ul id='L9MXa'></ul>
                  本文介紹了帶有數(shù)字選擇器的 Android PreferenceActivity 對話框的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我已經(jīng)看到了許多針對這個問題的定制解決方案和答案.我需要一些非常簡單的東西,我有一個偏好活動,我所需要的只是其中一個選項將打開帶有數(shù)字選擇器的對話框并保存結(jié)果.你能指導(dǎo)我一步一步地完成這個嗎?

                  I have seen many customized solutions and answers to this question. I need something very simple, I have a preference activity and all I need is that one of the options will open dialog with a number picker and save the results. Can you please guide me step by step with how to accomplish this?

                  public class SettingsActivity extends PreferenceActivity
                  {
                      @Override
                      protected void onCreate(final Bundle savedInstanceState)
                      {
                          super.onCreate(savedInstanceState);
                          getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferenceFragment()).commit();
                          //requestWindowFeature(Window.FEATURE_NO_TITLE);    
                      }
                  
                      public static class MyPreferenceFragment extends PreferenceFragment
                      {
                          @Override
                          public void onCreate(final Bundle savedInstanceState)
                          {
                              super.onCreate(savedInstanceState);
                              addPreferencesFromResource(R.xml.prefs);
                  
                          }
                      }
                  
                  }
                  

                  XML:

                      <SwitchPreference
                          android:key="cross"
                          android:summaryOff="Cross is invisible"
                          android:summaryOn="Cross is visible"
                          android:switchTextOff="OFF"
                          android:switchTextOn="ON"
                          android:title="Cross" 
                          android:defaultValue="true"/>
                  
                      <SwitchPreference
                          android:key="autoP"
                          android:summaryOff="App will go to sleep"
                          android:summaryOn="App will not go to sleep"
                          android:switchTextOff="OFF"
                          android:switchTextOn="ON"
                          android:title="Always On" 
                          android:defaultValue="true"/>
                  
                      <SwitchPreference
                          android:key="tempD"
                          android:summaryOff="Temprature not displayed"
                          android:summaryOn="Temprature displayed"
                          android:switchTextOff="OFF"
                          android:switchTextOn="ON"
                          android:title="Tempature Display" 
                          android:defaultValue="true"/>
                  
                      <ListPreference
                          android:entries="@array/units"
                          android:entryValues="@array/lunits"
                          android:key="listUnits"
                          android:summary="Units schosssing"
                          android:title="Units" android:defaultValue="C"/>
                  
                       <!--Need to add button to open dialog-->       
                  
                  </PreferenceScreen>
                  

                  數(shù)字選擇器 XML:

                  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent" >
                  
                      <NumberPicker
                          android:id="@+id/numberPicker1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentTop="true"
                          android:layout_centerHorizontal="true"
                          android:layout_marginTop="64dp" />
                  
                      <Button
                          android:id="@+id/button2"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_below="@+id/numberPicker1"
                          android:layout_marginLeft="20dp"
                          android:layout_marginTop="98dp"
                          android:layout_toRightOf="@+id/numberPicker1"
                          android:text="Cancel" />
                  
                      <Button
                          android:id="@+id/button1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignBaseline="@+id/button2"
                          android:layout_alignBottom="@+id/button2"
                          android:layout_marginRight="16dp"
                          android:layout_toLeftOf="@+id/numberPicker1"
                          android:text="Set" />
                  
                  </RelativeLayout>
                  

                  推薦答案

                  子類 DialogPreference 來構(gòu)建您自己的 NumberPickerPreference.

                  Subclass DialogPreference to build your own NumberPickerPreference.

                  我在下面為您實現(xiàn)了一個.它工作得很好,但功能不完整.例如,最小值和最大值是硬編碼的常量.這些實際上應(yīng)該是首選項 xml 聲明中的屬性.要讓它工作,您需要添加一個 attrs.xml 文件來指定您的自定義屬性.

                  I have implemented one below for you. It works perfectly fine, but is not feature complete. For example the minimum and maximum values are hard-coded constants. These should really be attributes on the preference xml declaration. To get that to work you would need to add an attrs.xml file specifying your custom attributes.

                  有關(guān)在庫項目中支持自定義 xml 屬性的 NumberPicker 首選項小部件的完整實現(xiàn)以及展示如何使用它的演示應(yīng)用,請參閱 GitHub:https://github.com/Alobar/AndroidPreferenceTest

                  For the full implementation of the NumberPicker preference widget that supports custom xml attributes in a library project and a demo app showing how to use it, see GitHub: https://github.com/Alobar/AndroidPreferenceTest

                  您可以將該小部件用作任何其他首選項小部件,除非您必須完全限定名稱:

                  You would use the widget as any other preference widget, except you have to fully qualify the name:

                  preferences.xml

                  <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
                  
                      <com.example.preference.NumberPickerPreference
                          android:key="key_number"
                          android:title="Give me a number"
                          android:defaultValue="55" />
                  
                  </PreferenceScreen>
                  

                  NumberPickerPreference.java

                  package com.example.preference;
                  
                  import android.content.Context;
                  import android.content.res.TypedArray;
                  import android.preference.DialogPreference;
                  import android.util.AttributeSet;
                  import android.view.Gravity;
                  import android.view.View;
                  import android.view.ViewGroup;
                  import android.widget.FrameLayout;
                  import android.widget.NumberPicker;
                  
                  /**
                   * A {@link android.preference.Preference} that displays a number picker as a dialog.
                   */
                  public class NumberPickerPreference extends DialogPreference {
                  
                      // allowed range
                      public static final int MAX_VALUE = 100;
                      public static final int MIN_VALUE = 0;
                      // enable or disable the 'circular behavior'
                      public static final boolean WRAP_SELECTOR_WHEEL = true; 
                  
                      private NumberPicker picker;
                      private int value;
                  
                      public NumberPickerPreference(Context context, AttributeSet attrs) {
                          super(context, attrs);
                      }
                  
                      public NumberPickerPreference(Context context, AttributeSet attrs, int defStyleAttr) {
                          super(context, attrs, defStyleAttr);
                      }
                  
                      @Override
                      protected View onCreateDialogView() {
                          FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
                                  ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                          layoutParams.gravity = Gravity.CENTER;
                  
                          picker = new NumberPicker(getContext());
                          picker.setLayoutParams(layoutParams);
                  
                          FrameLayout dialogView = new FrameLayout(getContext());
                          dialogView.addView(picker);
                  
                          return dialogView;
                      }
                  
                      @Override
                      protected void onBindDialogView(View view) {
                          super.onBindDialogView(view);
                          picker.setMinValue(MIN_VALUE);
                          picker.setMaxValue(MAX_VALUE);
                          picker.setWrapSelectorWheel(WRAP_SELECTOR_WHEEL);
                          picker.setValue(getValue());
                      }
                  
                      @Override
                      protected void onDialogClosed(boolean positiveResult) {
                          if (positiveResult) {
                              picker.clearFocus();
                              int newValue = picker.getValue();
                              if (callChangeListener(newValue)) {
                                  setValue(newValue);
                              }
                          }
                      }
                  
                      @Override
                      protected Object onGetDefaultValue(TypedArray a, int index) {
                          return a.getInt(index, MIN_VALUE);
                      }
                  
                      @Override
                      protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
                          setValue(restorePersistedValue ? getPersistedInt(MIN_VALUE) : (Integer) defaultValue);
                      }
                  
                      public void setValue(int value) {
                          this.value = value;
                          persistInt(this.value);
                      }
                  
                      public int getValue() {
                          return this.value;
                      }
                  }
                  

                  這篇關(guān)于帶有數(shù)字選擇器的 Android PreferenceActivity 對話框的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動期間獲取當(dāng)前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)
                • <i id='DLCyt'><tr id='DLCyt'><dt id='DLCyt'><q id='DLCyt'><span id='DLCyt'><b id='DLCyt'><form id='DLCyt'><ins id='DLCyt'></ins><ul id='DLCyt'></ul><sub id='DLCyt'></sub></form><legend id='DLCyt'></legend><bdo id='DLCyt'><pre id='DLCyt'><center id='DLCyt'></center></pre></bdo></b><th id='DLCyt'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='DLCyt'><tfoot id='DLCyt'></tfoot><dl id='DLCyt'><fieldset id='DLCyt'></fieldset></dl></div>
                    <tbody id='DLCyt'></tbody>

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

                          <bdo id='DLCyt'></bdo><ul id='DLCyt'></ul>
                          1. <legend id='DLCyt'><style id='DLCyt'><dir id='DLCyt'><q id='DLCyt'></q></dir></style></legend>
                          2. <tfoot id='DLCyt'></tfoot>
                          3. 主站蜘蛛池模板: 精品不卡| 伊人在线| 日韩在线精品强乱中文字幕 | 国产电影一区二区在线观看 | 九九九精品视频 | 亚洲欧洲成人av每日更新 | 亚洲精品 在线播放 | 国产精品久久久久久久岛一牛影视 | 久久av一区二区三区 | 久久久综合精品 | 欧美区日韩区 | 在线观看精品 | 日韩精品中文字幕一区二区三区 | 欧美成人在线网站 | 精品久久国产老人久久综合 | 午夜视频网站 | 欧美一级片在线播放 | 亚洲第一网站 | 中文字幕在线观看精品 | 免费a v网站 | 欧美一区二区三区的 | 国产视频一二三区 | av毛片在线| 午夜精品视频在线观看 | 在线播放国产一区二区三区 | 亚洲网站在线观看 | 久久久久亚洲国产| 成人三区 | 亚洲综合色视频在线观看 | 一区二区国产精品 | 日本一区二区三区四区 | 免费观看国产视频在线 | 美日韩免费视频 | 国产美女视频黄 | 日韩视频区| 91社影院在线观看 | 国产精品成人一区二区 | 国产一区h | 偷牌自拍 | 亚洲欧美综合精品久久成人 | 中文字幕在线播放不卡 |