-1
기본적으로 scrollview는 하나의 스크롤이기 때문에 datepicker에서 월과 년을 스크롤 할 수 없습니다.scrollview에 배치 할 때 DatePicker를 스크롤하는 방법
<DatePicker
android:layout_width="match_parent"
android:id="@+id/datePicker5"
android:layout_weight="3.61"
android:layout_height="match_parent" />
무엇을 추가해야합니까? 감사합니다
나는 또한이 코드가 btw 있습니다.
private void addPet(){
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(c);
View mView = layoutInflaterAndroid.inflate(R.layout.add_pet_dialog, null);
AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(c);
alertDialogBuilderUserInput.setView(mView);
final EditText userInputDialogEditText = (EditText) mView.findViewById(R.id.pet_name);
final DatePicker date_picker = (DatePicker) mView.findViewById(R.id.datepick);
date_picker.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event)
{
if (event.getAction() == MotionEvent.ACTION_DOWN) {
// Disallow the touch request for parent scroll on touch of datepicker view
requestDisallowParentInterceptTouchEvent(v, true);
}
else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
// Re-allows parent events
requestDisallowParentInterceptTouchEvent(v, false);
}
return false;
}
});
alertDialogBuilderUserInput
.setCancelable(false)
.setPositiveButton("Send", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogBox, int id) {
// ToDo get user input here
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogBox, int id) {
dialogBox.cancel();
}
});
AlertDialog alertDialogAndroid = alertDialogBuilderUserInput.create();
alertDialogAndroid.show();
}
private void requestDisallowParentInterceptTouchEvent(View v, Boolean disallowIntercept) {
while (v.getParent() != null && v.getParent() instanceof View) {
if (v.getParent() instanceof ScrollView) {
v.getParent().requestDisallowInterceptTouchEvent(disallowIntercept);
}
v = (View) v.getParent();
}
}
나는 아직도 그것이 작동하지 않는 이유를 알고있다.
). –
@ Dr.DOOM 전체 XML 파일을 공유 할 수 있습니까? – Basanth