次のエントリ: LaunchWatchをリリースしました [Android]
PreferenceScreenに依存設定(dependency)を行ってチェックオフ時は操作不可
2011-07-25-1 / カテゴリ: [Android] / [permlink]
[2011-07-03-1]の各設定を「通信を許可」というチェックがonの場合のみ操作できるようにしてみる。

チェックボックスを追加して

属性を設定(手抜き見やすくするために 以下同文)


全体でこんな感じ
で、こうなる。
左がチェックoff(disable)で、右がチェックon

さらに、子要素用のレイアウト指定をすることで(図はわかりにくいけど)若干インデントが掛かる

xml(抜粋) はこんな感じ

「通信を許可」のチェックボックス追加
ここは簡単に。チェックボックスを追加して

属性を設定(

依存の設定
既存の「SSL(チェックボックス)」「サイト名(EditText)」「端末(List)」それぞれの「Dependency」に、追加した「通信を許可」のKeyを設定する。
全体でこんな感じ
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <CheckBoxPreference android:title="通信" android:key="enable_transmit" android:summary="通信を許可" ></CheckBoxPreference> <CheckBoxPreference android:summary="SSLを使用する" android:key="usessl" android:title="SSL" android:dependency="enable_transmit" ></CheckBoxPreference> <EditTextPreference android:key="name" android:title="サイト名" android:summary="サイトの名称" android:dependency="enable_transmit" ></EditTextPreference> <ListPreference android:key="list" android:entryValues="@array/listpref_value" android:entries="@array/listpref_entries" android:title="端末" android:summary="端末を選択" android:dependency="enable_transmit" ></ListPreference> </PreferenceScreen>
で、こうなる。
左がチェックoff(disable)で、右がチェックon


さらに、子要素用のレイアウト指定をすることで(図はわかりにくいけど)若干インデントが掛かる

xml(抜粋) はこんな感じ
<CheckBoxPreference android:summary="SSLを使用する" android:key="usessl" android:title="SSL" android:dependency="enable_transmit" android:layout="?android:attr/preferenceLayoutChild" ></CheckBoxPreference>
[
コメント ]
次のエントリ: LaunchWatchをリリースしました [Android]
2013 : 01 02 03 04 05 06 07 08 09 10 11 12
2012 : 01 02 03 04 05 06 07 08 09 10 11 12
2011 : 01 02 03 04 05 06 07 08 09 10 11 12
2010 : 01 02 03 04 05 06 07 08 09 10 11 12
2009 : 01 02 03 04 05 06 07 08 09 10 11 12
2008 : 01 02 03 04 05 06 07 08 09 10 11 12
2007 : 01 02 03 04 05 06 07 08 09 10 11 12
2006 : 01 02 03 04 05 06 07 08 09 10 11 12
2005 : 01 02 03 04 05 06 07 08 09 10 11 12
2004 : 01 02 03 04 05 06 07 08 09 10 11 12
最終更新時間: 2013-05-02 16:12