Android:如何在警报对话框中添加水平滚动的列表项

时间:2019-07-15 10:41:32

标签: android android-listview alertdialog android-alertdialog

我想知道如何在“警报对话框”中水平滚动设置“列表项”。我的文字太长,我不想再下一行。

这是我目前添加商品的方式:

AlertDialog.Builder builder = new AlertDialog.Builder(ContextActivity);

builder.setTitle(dialogTitel);
final CharSequence[] aList = new CharSequence[items.size()];

Integer i = 0;
    for (Map.Entry<Integer, String> entry : items.entrySet()) {
         sDescription = entry.getValue();
            aList[i] = sDescription;
            i++;
        }



builder.setItems(aList, new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialogInterface, int item) {

  CharSequence sDescription = aListe[item];
        Integer iId = 0;
        for (Map.Entry<Integer, String> entry : items.entrySet()) {
               if (entry.getValue() == sDescription) {
                     iId = entry.getKey();
                   }
                }

                OnDialogSelected(iId, sDescription, button);
            }
        });

0 个答案:

没有答案