android.app.AlertDialog.getListView()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中android.app.AlertDialog.getListView()方法的一些代码示例,展示了AlertDialog.getListView()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AlertDialog.getListView()方法的具体详情如下:
包路径:android.app.AlertDialog
类名称:AlertDialog
方法名:getListView

AlertDialog.getListView介绍

暂无

代码示例

代码示例来源:origin: k9mail/k-9

@Override
  public void onClick(DialogInterface dialog, int which, boolean isChecked) {
    ((AlertDialog) dialog).getListView().setItemChecked(which, isChecked);
  }
};

代码示例来源:origin: robolectric/robolectric

/**
 * Simulates a click on the {@code Dialog} item indicated by {@code index}. Handles both multi- and single-choice dialogs, tracks which items are currently
 * checked and calls listeners appropriately.
 *
 * @param index the index of the item to click on
 */
public void clickOnItem(int index) {
 ShadowListView shadowListView = Shadow.extract(realAlertDialog.getListView());
 shadowListView.performItemClick(index);
}

代码示例来源:origin: k9mail/k-9

@Override
public boolean retain() {
  if (mDialog != null) {
    // Save the selection state of each list item
    mSelection = mDialog.getListView().getCheckedItemPositions();
    mDialog.dismiss();
    mDialog = null;
    return true;
  }
  return false;
}

代码示例来源:origin: k9mail/k-9

@Override
  public void onClick(DialogInterface dialog, int which) {
    ListView listView = ((AlertDialog) dialog).getListView();
    SparseBooleanArray pos = listView.getCheckedItemPositions();
    boolean includeGlobals = mImportContents.globalSettings && pos.get(0);
    List<String> accountUuids = new ArrayList<>();
    int start = mImportContents.globalSettings ? 1 : 0;
    for (int i = start, end = listView.getCount(); i < end; i++) {
      if (pos.get(i)) {
        accountUuids.add(mImportContents.accounts.get(i - start).uuid);
      }
    }
    /*
     * TODO: Think some more about this. Overwriting could change the store
     * type. This requires some additional code in order to work smoothly
     * while the app is running.
     */
    boolean overwrite = false;
    dialog.dismiss();
    activity.setNonConfigurationInstance(null);
    ImportAsyncTask importAsyncTask = new ImportAsyncTask(activity,
        includeGlobals, accountUuids, overwrite, mUri);
    activity.setNonConfigurationInstance(importAsyncTask);
    importAsyncTask.execute();
  }
});

代码示例来源:origin: termux/termux-app

ListView lv = dialog.getListView(); // this is a ListView with your "buds" in it
lv.setOnItemLongClickListener((parent, view, position, id) -> {
  dialog.dismiss();

代码示例来源:origin: hidroh/materialistic

@Config(sdk = 21)
@Test
public void testRemoveAccount() {
  AccountManager.get(activity).addAccountExplicitly(new Account("existing",
      BuildConfig.APPLICATION_ID), "password", null);
  Preferences.setUsername(activity, "existing");
  drawerAccount.performClick();
  AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
  assertNotNull(alertDialog);
  assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
  alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).performClick();
  assertThat(alertDialog).isNotShowing();
  assertThat(AccountManager.get(activity).getAccounts()).isEmpty();
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testExistingAccount() {
  AccountManager.get(activity).addAccountExplicitly(new Account("existing",
      BuildConfig.APPLICATION_ID), "password", null);
  drawerAccount.performClick();
  AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
  assertNotNull(alertDialog);
  assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
  shadowOf(alertDialog).clickOnItem(0);
  alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
  assertThat(alertDialog).isNotShowing();
  assertThat(drawerAccount).hasText("existing");
  assertThat(drawerLogout).isVisible();
  drawerAccount.performClick();
  alertDialog = ShadowAlertDialog.getLatestAlertDialog();
  assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
}

代码示例来源:origin: stackoverflow.com

AlertDialog alertDialogObject = dialogBuilder.create();
ListView listView=alertDialogObject.getListView();  
listView.setDivider(new ColorDrawable(Color.BLUE)); // set color
listView.setDividerHeight(2); // set height 
alertDialogObject.show();

代码示例来源:origin: hidroh/materialistic

@Test
public void testAddAccount() {
  AccountManager.get(activity).addAccountExplicitly(new Account("existing",
      BuildConfig.APPLICATION_ID), "password", null);
  drawerAccount.performClick();
  AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
  assertNotNull(alertDialog);
  assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
  alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
  assertThat(alertDialog).isNotShowing();
  ((ShadowSupportDrawerLayout) Shadow.extract(activity.findViewById(R.id.drawer_layout)))
      .getDrawerListeners().get(0)
      .onDrawerClosed(activity.findViewById(R.id.drawer));
  assertThat(shadowOf(activity).getNextStartedActivity())
      .hasComponent(activity, LoginActivity.class);
}

代码示例来源:origin: stackoverflow.com

int position = alert.getListView().getCheckedItemPosition();

代码示例来源:origin: stackoverflow.com

AlertDialog alert = builder.create();
                 alert.getListView().setSelector(R.drawable.listview_selector);
                 alert.getListView().setBackgroundColor(Color.RED);
                 alert.getListView().invalidate();
               alert.show();

代码示例来源:origin: stackoverflow.com

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
  switch (id) {
    case DIALOG_REVIEW:
      ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.select_dialog_singlechoice, android.R.id.text1, phoneNums);
      AlertDialog ad = (AlertDialog) dialog;
      ad.getListView().setAdapter(adapter);
    break;
    default:
      super.onPrepareDialog(id, dialog);
  }
}

代码示例来源:origin: stackoverflow.com

AlertDialog alertDialog = builder.create();
ListView listView = alertDialog.getListView();
listView.setOnItemClickListener(new OnItemClickListener() {

  @Override
  public void onItemClick(AdapterView<?> parent, View view,
      int position, long id) {
    // TODO Auto-generated method stub

  }
});

代码示例来源:origin: FacePlusPlus/MegviiFacepp-Android-SDK

public void showTrackModel(final TextView textView){
  RadioOnClick OnClick = new RadioOnClick(textView);
  AlertDialog ad =new Builder(activity).setTitle(activity.getResources().getString(R.string.trackig_mode))
      .setSingleChoiceItems(R.array.trackig_mode_array,OnClick.getIndex(),OnClick).create();
  ListView areaListView=ad.getListView();
  ad.show();
}

代码示例来源:origin: dariopellegrini/FormBuilder

@Override
  public void onClick(DialogInterface dialogInterface, int i) {
    dialogInterface.dismiss();
    int selectedPosition = ((AlertDialog)dialogInterface).getListView().getCheckedItemPosition();
    selectedElements.add(selectedFormElement.getOptions().get(selectedPosition));
    selectedFormElement.setOptionsSelected(selectedElements);
    selectedEditText.setText(selectedFormElement.getOptionsSelected().toString());
  }
});

代码示例来源:origin: org.robolectric/shadows-core

/**
 * Simulates a click on the {@code Dialog} item indicated by {@code index}. Handles both multi- and single-choice dialogs, tracks which items are currently
 * checked and calls listeners appropriately.
 *
 * @param index the index of the item to click on
 */
public void clickOnItem(int index) {
 Shadows.shadowOf(realAlertDialog.getListView()).performItemClick(index);
}

代码示例来源:origin: org.robolectric/shadows-framework

/**
 * Simulates a click on the {@code Dialog} item indicated by {@code index}. Handles both multi- and single-choice dialogs, tracks which items are currently
 * checked and calls listeners appropriately.
 *
 * @param index the index of the item to click on
 */
public void clickOnItem(int index) {
 ShadowListView shadowListView = Shadow.extract(realAlertDialog.getListView());
 shadowListView.performItemClick(index);
}

代码示例来源:origin: stackoverflow.com

private static final int specialItem = ...;
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
  if (which == singleItem) { // only if they clicked 'none'
    final AlertDialog alertDialog = (AlertDialog) dialog;
    final ListView alertDialogList = alertDialog.getListView();

    for (int position = 0; position < alertDialogList.getChildCount(); position++)
    {
      if (position != which) {
        alertDialogList.getChildAt(position).setEnabled(!isChecked);
      }
    }
  }
}

代码示例来源:origin: vanilla-music/vanilla

@Override
public void onDismiss(DialogInterface dialog)
{
  ListView list = ((AlertDialog)dialog).getListView();
  int which = list.getCheckedItemPosition();
  CheckBox reverseSort = (CheckBox)list.findViewById(R.id.reverse_sort);
  if (reverseSort.isChecked()) {
    which = ~which;
  }
  mPagerAdapter.setSortMode(which);
}

代码示例来源:origin: hypeapps/Endoscope

@Override
  public void onClick(DialogInterface dialogInterface, int selectedOption) {
    int selectedPosition = ((AlertDialog) dialogInterface).getListView().getCheckedItemPosition();
    Log.e("Option", " " + selectedPosition);
    if (option.equals(OPTION_VIDEO_ENCODER)) {
      getPresenter().onChangeVideoEncoder(selectedPosition);
    } else if (option.equals(OPTION_RESOLUTION)) {
      getPresenter().onChangeResolution(selectedPosition);
    }
  }
})

相关文章