EditTextPreference はダイアログ内の EditText をコードから生成し、Id として com.android.internal.R.id.edit をセットしています。
http://tools.oesf.biz/android-4.4.0_r1.0/xref/frameworks/base/core/java/android/preference/EditTextPreference.java#53
- 45 public class EditTextPreference extends DialogPreference {
- 46 /**
- 47 * The edit text shown in the dialog.
- 48 */
- 49 private EditText mEditText;
- 50
- 51 private String mText;
- 52
- 53 public EditTextPreference(Context context, AttributeSet attrs, int defStyle) {
- 54 super(context, attrs, defStyle);
- 55
- 56 mEditText = new EditText(context, attrs);
- 57
- 58 // Give it an ID so it can be saved/restored
- 59 mEditText.setId(com.android.internal.R.id.edit);
- 60
- 61 /*
- 62 * The preference framework and view framework both have an 'enabled'
- 63 * attribute. Most likely, the 'enabled' specified in this XML is for
- 64 * the preference framework, but it was also given to the view framework.
- 65 * We reset the enabled state.
- 66 */
- 67 mEditText.setEnabled(true);
- 68 }
- public void testEditTextPreference() {
- // EditTextPreference をクリック
- onData(withPreferenceKey("edit_text_pref1")).perform(click());
- onView(isAssignableFrom(EditText.class)).perform(clearText(), new InputTextAction("エスプレッソよりカフェラテ派"));
- onView(withText("OK")).perform(click());
- // 例えば入力値が summary に表示されるような実装になっているなら、それをチェックできる
- onData(withPreferenceKey("edit_text_pref1"))
- .onChildView(withId(android.R.id.summary))
- .check(matches(withText("エスプレッソよりカフェラテ派")));
- }
0 件のコメント:
コメントを投稿