2014-11-20 3 views
1

저는 약간의 수정 된 NumberPicker를 사용하며 작업이 시작될 때 기본값이 이미 선택되어 있습니다. 이것은 키보드를 불러 오거나 잘라 내기/복사/붙여 넣기 대화 상자를 불러 오기 때문에 성가신 일입니다. 키보드를 내려 놓으라고 지시했지만 여전히 선택되어 있으며 잘라 내기/복사/붙여 넣기 대화 상자가 나타납니다. 값을 스크롤하면 더 이상 숫자가 선택되지 않고 정상적으로 작동합니다. 누구든지 시작할 때 선택하지 않은 NumberPicker를 설정하는 방법을 알고 있습니까?Android NumberPicker 번호 선택 해제

@TargetApi(Build.VERSION_CODES.HONEYCOMB) 
public class NumPicker extends NumberPicker 
{ 
public NumPicker(Context context) 
{ 
    super(context); 
} 

public NumPicker(Context context, AttributeSet attrs) 
{ 
    super(context, attrs); 
    processAttributeSet(attrs); 
} 

public NumPicker(Context context, AttributeSet attrs, int defStyle) 
{ 
    super(context, attrs, defStyle); 
    processAttributeSet(attrs); 
} 

/** 
* Reads the xml, sets the properties 
*/ 
private void processAttributeSet(AttributeSet attrs) 
{ 
    setMinValue(attrs.getAttributeIntValue(null, "min", 0)); 
    setMaxValue(attrs.getAttributeIntValue(null, "max", 0)); 
    setValue(4); 
} 
} 

이는이 XML에 사용되는 방법은 다음과 같습니다 (? 또는 유일한) 이런

android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentTop="true" 
    android:layout_marginRight="50dp" 
    android:layout_marginEnd="50dp" 
    android:layout_marginTop="40dp" 
    style="@style/CustomText" 
    max="100" 
    min="2" 

답변

2

이유는 NumberPicker이 활동의 ​​첫 번째 포커스 요소 것입니다. 루트보기에이 속성을 추가하여 기본 레이아웃보기에 포커스를 트랩 할 수 있습니다.

android:focusableInTouchMode="true" 
+0

NumPicker 클래스와 내 활동에서 clearFocus()를 시도했습니다. 어느 쪽도 차이를 만들지 않았습니다. – Rand

+0

업데이트 된 답변으로 문제가 해결 되었습니까? –

+0

네, 감사합니다. 나는 textviews 또는 단추에 초점을 이동하는 시도했다 그러나 나는 끝날 수 없다는 것을 짐작한다. – Rand

관련 문제