2010-08-20 8 views
5

Je souhaite utiliser FastScroll pour ma liste d'historique et utiliser des dates pour les sections, mais la boîte de dialogue d'alerte (qui affiche les lettres dans les contacts) ne s'étire pas selon la taille du texte.Redimensionner la boîte de dialogue FastScroll

Comment puis-je le redimensionner?

+0

Progression en cours? Avez-vous essayé ma suggestion? – gary

Répondre

1

Ma solution. Nous désactivons la fonctionnalité Fastscroll intégrée et utilisons le code this avec des modifications mineures. La variable mOverlaySize est responsable de la taille des alertes de section.

1

Se pourrait-il que ce soit quelque chose d'aussi simple que d'utiliser setView dans la classe AlertDialog? (Avec quelques modifications au fichier .xml). Tout d'abord, j'ai pris des informations sur setView de here.

public void setView (View view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight, int viewSpacingBottom) 

Set the view to display in that dialog, specifying the spacing to appear around that view.  
Parameters: 
view The view to show in the content area of the dialog 
viewSpacingLeft Extra space to appear to the left of view 
viewSpacingTop Extra space to appear above view 
viewSpacingRight Extra space to appear to the right of view 
viewSpacingBottom Extra space to appear below view 

Et voici quelques exemples de code de SDK (AlertDialogSamples.java) qui utilise setView.

case DIALOG_TEXT_ENTRY: 
      // This example shows how to add a custom layout to an AlertDialog 
      LayoutInflater factory = LayoutInflater.from(this); 
      final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null); 
      return new AlertDialog.Builder(AlertDialogSamples.this) 
       .setIcon(R.drawable.alert_dialog_icon) 
       .setTitle(R.string.alert_dialog_text_entry) 
       .setView(textEntryView) 
       .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int whichButton) { 

         /* User clicked OK so do some stuff */ 
        } 
       }) 
       .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int whichButton) { 

         /* User clicked cancel so do some stuff */ 
        } 
       }) 
       .create(); 
     } 
     return null; 

Et enfin, une partie du fichier xml ressemble il ajoute des marges autour du texte (alert_dialog_text_entry.xml).

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/username_view" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_marginLeft="20dip" 
     android:layout_marginRight="20dip" 
     android:text="@string/alert_dialog_username" 
     android:gravity="left" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 

Espérons que cela aide.

+0

Comment cela peut-il être appliqué au FastScroll? Désolé de la réponse tardive. –

Questions connexes