Java Code Examples for android.app.AlertDialog#getListView()

The following examples show how to use android.app.AlertDialog#getListView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccountsSettingsFragmentTests.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public void testMultipleAccounts_noCurrentAccount() {
    when(mManagedProfileUtils.hasWorkProfile(any(Context.class))).thenReturn(false);

    final AccountsSettingsFragment fragment =
            (AccountsSettingsFragment) getActivity().mFragment;
    final AlertDialog dialog = initDialog(fragment, null).mDialog;
    final ListView lv = dialog.getListView();

    // The 1st account should be checked by default.
    assertEquals("checked-item", 0, lv.getCheckedItemPosition());
    // There should be 4 accounts in the list.
    assertEquals("count", 4, lv.getCount());
    // The sign-out button shouldn't exist
    assertEquals(View.GONE,
            dialog.getButton(DialogInterface.BUTTON_NEUTRAL).getVisibility());
    assertEquals(View.VISIBLE,
            dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getVisibility());
    assertEquals(View.VISIBLE,
            dialog.getButton(DialogInterface.BUTTON_POSITIVE).getVisibility());
}
 
Example 2
Source File: AccountsSettingsFragmentTests.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public void testMultipleAccounts_currentAccount() {
    when(mManagedProfileUtils.hasWorkProfile(any(Context.class))).thenReturn(false);

    final AccountsSettingsFragment fragment =
            (AccountsSettingsFragment) getActivity().mFragment;
    final AlertDialog dialog = initDialog(fragment, "[email protected]").mDialog;
    final ListView lv = dialog.getListView();

    // The 3rd account should be checked by default.
    assertEquals("checked-item", 2, lv.getCheckedItemPosition());
    // There should be 4 accounts in the list.
    assertEquals("count", 4, lv.getCount());
    // The sign-out button should be shown
    assertEquals(View.VISIBLE,
            dialog.getButton(DialogInterface.BUTTON_NEUTRAL).getVisibility());
    assertEquals(View.VISIBLE,
            dialog.getButton(DialogInterface.BUTTON_NEGATIVE).getVisibility());
    assertEquals(View.VISIBLE,
            dialog.getButton(DialogInterface.BUTTON_POSITIVE).getVisibility());
}
 
Example 3
Source File: DialogUtil.java    From MegviiFacepp-Android-SDK with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 4
Source File: RootMode.java    From rebootmenu with GNU General Public License v3.0 5 votes vote down vote up
private void parcelOtherUIAction(AlertDialog dialog) {
    ListView listView = dialog.getListView();
    UIUtils.addMagnifier(listView);
    listView.setOnItemLongClickListener((parent, view, position, id) -> {
        switch (position) {
            case 0:
                UIUtils.addLauncherShortcut(this, R.string.reboot, android.R.drawable.ic_menu_rotate, Shortcut.REBOOT, true);
                break;
            case 1:
                UIUtils.addLauncherShortcut(this, R.string.shutdown, android.R.drawable.ic_menu_delete, Shortcut.SHUTDOWN, true);
                break;
            case 2:
                UIUtils.addLauncherShortcut(this, R.string.recovery_short, android.R.drawable.ic_menu_today, Shortcut.RECOVERY, true);
                break;
            case 3:
                UIUtils.addLauncherShortcut(this, R.string.fastboot_short, android.R.drawable.ic_menu_sort_by_size, Shortcut.FASTBOOT, true);
                break;
            case 4:
                //热重启是一种永远都不被推荐的重启方式,它造成系统不稳定的可能性很大,所以使用截图警示图标
                UIUtils.addLauncherShortcut(this, R.string.hot_reboot, android.R.drawable.ic_menu_report_image, Shortcut.HOT_REBOOT, false);
                break;
            case 5:
                UIUtils.addLauncherShortcut(this, R.string.rebootui_short, android.R.drawable.ic_menu_view, Shortcut.REBOOT_UI, false);
                break;
            case 6:
                //用于定点清除故障应用的安全模式,使用位置图标
                UIUtils.addLauncherShortcut(this, R.string.safety, android.R.drawable.ic_menu_mylocation, Shortcut.SAFEMODE, false);
                break;
            case 7:
                UIUtils.addLauncherShortcut(this, R.string.lockscreen, android.R.drawable.ic_menu_slideshow, Shortcut.LOCKSCREEN, false);
        }
        new TextToast(this, true, String.format(getString(R.string.launcher_shortcut_added), uiTextList[position]));
        return true;
    });
}
 
Example 5
Source File: ThemePreferenceAdapter.java    From NMSAlphabetAndroidApp with MIT License 5 votes vote down vote up
@Override
protected void showDialog(Bundle state) {
    super.showDialog(state);
    AlertDialog dialog = (AlertDialog) getDialog();
    ListView listView = dialog.getListView();
    ListPrefWrapperAdapter fontTypeAdapter = new ListPrefWrapperAdapter(listView.getAdapter());
    listView.setAdapter(fontTypeAdapter);
    int selectedPosition = findIndexOfValue(getValue());
    if (selectedPosition != -1) {
        listView.setItemChecked(selectedPosition, true);
        listView.setSelection(selectedPosition);
    }
}
 
Example 6
Source File: AccountsSettingsFragmentTests.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public void testMultipleAccounts_noSettingsForManagedProfile() {
    when(mManagedProfileUtils.hasWorkProfile(any(Context.class))).thenReturn(true);

    final AccountsSettingsFragment fragment =
            (AccountsSettingsFragment) getActivity().mFragment;
    final AlertDialog dialog = initDialog(fragment, null).mDialog;
    final ListView lv = dialog.getListView();

    // Nothing to check/uncheck.
    assertNull(fragment.findPreference(AccountsSettingsFragment.PREF_ACCCOUNT_SWITCHER));
}