처럼 이동하려는 것입니다 내가 날짜와 시간에 사용하는 내 번호 선택기 :
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.NumberPicker;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)//For backward-compability
public class NumberPickerMinMax extends NumberPicker
{
public NumberPickerMinMax(Context context)
{
super(context);
}
public NumberPickerMinMax(Context context, AttributeSet attrs)
{
super(context, attrs);
processAttributeSet(attrs);
}
public NumberPickerMinMax(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
processAttributeSet(attrs);
}
private void processAttributeSet(AttributeSet attrs)
{
//This method reads the parameters given in the xml file and sets the properties according to it
this.setMinValue(attrs.getAttributeIntValue(null, "min", 0));
this.setMaxValue(attrs.getAttributeIntValue(null, "max", 0));
}
}
지금 당신은 시간의 각 숫자 4 NumberPickerMinMax
을 추가해야합니다 : HH : mm, 여기 내 레이아웃입니다 :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<com.evapp.customViews.NumberPickerMinMax
android:id="@+id/TimePickerView_hour2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
min="0"
max="9"
android:layout_toLeftOf="@+id/textView1" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=" - "
android:textAppearance="?android:attr/textAppearanceLarge" />
<com.evapp.customViews.NumberPickerMinMax
android:id="@+id/TimePickerView_hour1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_margin="2dp"
min="0"
max="2"
android:layout_toLeftOf="@+id/TimePickerView_hour2" />
<com.evapp.customViews.NumberPickerMinMax
android:id="@+id/TimePickerView_minutes1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
min="0"
max="5"
android:layout_toRightOf="@+id/textView1" />
<com.evapp.customViews.NumberPickerMinMax
android:id="@+id/TimePickerView_minutes2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="2dp"
min="0"
max="9"
android:layout_toRightOf="@+id/TimePickerView_minutes1" />
</RelativeLayout>
</RelativeLayout>
H 이게 당신이 필요로하는 것입니다.
달성하고자하는 것을 설명해 주시겠습니까? 나는 당신의 문제를 이해하지 못합니다. –