Comment puis-je afficher un CalendarView dans un AlertDialog?
J'essaie d'afficher le CalendarView dans une boîte de Dialogue d'Alerte, mais tout ce qui s'affiche est le mois et l'année et les jours de la semaine.
Ce sont le contenu du fichier de mise en page:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<CalendarView
android:id="@+id/calendarID"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/cal_desc"
android:maxDate="01/01/2013"
android:minDate="09/01/2012"
android:showWeekNumber="false"
android:tag="my tag" />
</LinearLayout>
C'est le code que j'ai utilisé pour ajouter de la mise en page d'un AlertDialog:
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout ll= (LinearLayout)inflater.inflate(R.layout.myLayout, null, false);
CalendarView cv = (CalendarView) ll.getChildAt(0);
cv.setOnDateChangeListener(new OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
int dayOfMonth) {
//TODO Auto-generated method stub
initScheduleEvent();
}
});
new AlertDialog.Builder(MomAppActivity.this)
.setTitle("Event Calendar")
.setMessage("Click to schedule or view events.")
.setView(ll)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//do nothing...yet
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//Do nothing.
}
}
).show();
Toute aide serait grandement apprécié de voir que je suis complètement déconcerté. L'application n'est pas en me donnant toutes les erreurs d'aller sur.
OriginalL'auteur PlayerGurl89 | 2012-09-08
Vous devez vous connecter pour publier un commentaire.
Une hauteur minimum est requis pour le calendrier afin d'afficher correctement. Le reste du code a bien fonctionné.
OriginalL'auteur PlayerGurl89
Essayer cette CalendarDialogBuilder
OriginalL'auteur Heitor Colangelo
Si vous souhaitez un design personnalisé pour une boîte de dialogue, vous pouvez créer votre propre mise en page de la fenêtre de dialogue de mise en page et widget éléments.
essayez ces liens, j'espère que vous trouverez votre réponse
http://www.mkyong.com/android/android-custom-dialog-example/
http://developer.android.com/guide/topics/ui/dialogs.html
http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application
OriginalL'auteur Deepak Swami