2010-08-20 86 views
5

我想爲我的歷史記錄列表使用FastScroll併爲段落使用日期,但警報對話框(顯示聯繫人中的字母)不能伸展以適應文本的大小(我想在月份和日期顯示)。調整FastScroll警報對話框

我該如何調整它?

+0

有沒有進展?你有沒有試過我的建議? – gary 2010-09-07 16:22:07

回答

1

我的解決方案。 我們禁用了內置Fastscroll功能,並使用this代碼進行了小的更改。變量mOverlaySize負責部分警報的大小。

1

它可以像在AlertDialog類中使用setView一樣簡單嗎? (除了對.xml的一些編輯)。首先,我從here獲取有關setView的信息。

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 

而且這裏的一些SDK的示例代碼(AlertDialogSamples.java),使用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; 

最後,一些xml文件看起來像它增加了旁的文字(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" /> 

希望它有幫助。

+0

這如何應用於FastScroll?對不起,遲到的答案。 – 2010-09-20 09:16:49