Java Code Examples for android.widget.ListView#setChoiceMode()

The following examples show how to use android.widget.ListView#setChoiceMode() . These examples are extracted from open source projects. 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
@Override
public void onResume() {
	super.onResume();
	
	final ListView permsList = (ListView) findViewById(R.id.permissions_list);
	
	permsList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
	permsList.setItemsCanFocus(false);
	
	checked = new boolean[Manifest.permissions.size()];
	for (int i = 0; i < checked.length; i ++) {
		checked[i] = false;
	}
	
	if (isPreviewSetttings) {
		loadDataPreviewSettings();
	} else {
		loadData();
	}
	
	adapter = new PermissionAdapter();
	permsList.setAdapter(adapter);
}
 
Example 2
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // View management
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);

    // Modify list view
    ListView lv = getListView();
    lv.setVerticalFadingEdgeEnabled(true);
    // lv.setCacheColorHint(android.R.color.transparent);
    if (mDualPane) {
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        lv.setItemsCanFocus(false);
    } else {
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        lv.setItemsCanFocus(true);
    }
}
 
Example 3
Source Project: Mizuu   File: UnidentifiedMovies.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	mList = (ListView) findViewById(R.id.listView1);
	mList.setChoiceMode(ListView.CHOICE_MODE_NONE);
	mList.setOnItemClickListener(new OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
			Intent intent = new Intent(UnidentifiedMovies.this, IdentifyMovie.class);
			intent.putExtra("fileName", mFilepaths.get(arg2).getFullFilepath());
			startActivityForResult(intent, 0);
		}
	});

	loadData();

	LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.UPDATE_MOVIE_LIBRARY));
}
 
Example 4
private void showAddress(final DrawableRecipientChip currentChip,final ListPopupWindow popup,final int width)
{
if(!mAttachedToWindow)
  return;
final int line=getLayout().getLineForOffset(getChipStart(currentChip));
final int bottom=calculateOffsetFromBottom(line);
// Align the alternates popup with the left side of the View,
// regardless of the position of the chip tapped.
popup.setWidth(width);
popup.setAnchorView(this);
popup.setVerticalOffset(bottom);
popup.setAdapter(createSingleAddressAdapter(currentChip));
popup.setOnItemClickListener(new OnItemClickListener()
  {
    @Override
    public void onItemClick(final AdapterView<?> parent,final View view,final int position,final long id)
      {
      unselectChip(currentChip);
      popup.dismiss();
      }
  });
popup.show();
final ListView listView=popup.getListView();
listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
listView.setItemChecked(0,true);
}
 
Example 5
private void initializeListView() {
  listView = (ListView) findViewById(R.id.activity_choosefiltersandactions_listview);

  adapterRule = new AdapterRule(this, listView);

  listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  listView.setAdapter(adapterRule);

  // Set the adapter to render the rule stored in RuleBuilder.
  // It may be a brand new rule or a saved rule being edited.
  adapterRule.setRule(RuleBuilder.instance().getRule());
  registerForContextMenu(listView);
}
 
Example 6
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	super.onCreateView(inflater, container, savedInstanceState);
	View v = inflater.inflate(R.layout.layout_list, container,false);
	ListView listView = (ListView) v.findViewById(android.R.id.list);
	listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
	registerForContextMenu(listView);
	listView.setMultiChoiceModeListener(new ListViewMultiChoiceModeListener(
			context,getActivity(),
			listView,mRootScreen,
			false,
			MainActivity.db,
			MainActivity.vddDb));
	return v;
}
 
Example 7
Source Project: CanDialog   File: CanDialog.java    License: Apache License 2.0 5 votes vote down vote up
public void setSingleChoiceItems(final CharSequence[] mItems, int checkedItem,
                                 final CanDialogInterface.OnClickListener listener) {

    setType(DIALOG_SINGLE_CHOICE);

    mDialog.checkedItem = checkedItem;

    final ListView listView = (ListView) LayoutInflater.from(mContext).inflate(R.layout.dialog_list, null);


    CheckedItemAdapter adapter = new CheckedItemAdapter(mContext, R.layout.dialog_singchoice, android.R.id.text1, mItems);

    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {

            mDialog.checkedItem = position;
            if (listener != null) {
                listener.onClick(mDialog, position, mItems[position], null);
            }
        }
    });

    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setItemChecked(checkedItem, true);
    showListOrEditView(listView);
}
 
Example 8
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // View management
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);


    // Modify list view
    ListView lv = getListView();
    lv.setVerticalFadingEdgeEnabled(true);
    // lv.setCacheColorHint(android.R.color.transparent);
    if (mDualPane) {
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        lv.setItemsCanFocus(false);
    } else {
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        lv.setItemsCanFocus(true);
    }
    
    // Map long press
    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> ad, View v, int pos, long id) {
            turnOnActionMode();
            getListView().setItemChecked(pos, true);
            mMode.invalidate();
            return true;
        }
    });
}
 
Example 9
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_page, container, false);
    ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle());

    final ListView listView = (ListView) rootView.findViewById(android.R.id.list);
    setListAdapter(new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_list_item_single_choice,
            android.R.id.text1,
            mChoices));
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    // Pre-select currently selected item.
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            String selection = mPage.getData().getString(Page.SIMPLE_DATA_KEY);
            for (int i = 0; i < mChoices.size(); i++) {
                if (mChoices.get(i).equals(selection)) {
                    listView.setItemChecked(i, true);
                    break;
                }
            }
        }
    });

    return rootView;
}
 
Example 10
Source Project: SmileEssence   File: EditExtractionActivity.java    License: MIT License 5 votes vote down vote up
private void initializeViews() {
    ListView listView = getListView();
    adapter = new CustomListAdapter<>(this, ExtractionWord.class);
    listView.setAdapter(adapter);
    adapter.addToTop(getExtractionWords());
    adapter.update();
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setOnItemClickListener(this);
    listView.setMultiChoiceModeListener(this);
}
 
Example 11
private void initMap() {
    //ricky init baidumap begin
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
    mMapView.showZoomControls(false);
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17.0f);
    mBaiduMap.setMapStatus(msu);
    mBaiduMap.setOnMapTouchListener(touchListener);
    // 初始化POI信息列表
    mInfoList = new ArrayList<PoiInfo>();
    // 初始化当前MapView中心屏幕坐标,初始化当前地理坐标
    mCenterPoint = mBaiduMap.getMapStatus().targetScreen;
    mLoactionLatLng = mBaiduMap.getMapStatus().target;
    // 定位
    mBaiduMap.setMyLocationEnabled(true);
    // 隐藏百度logo ZoomControl
    int count = mMapView.getChildCount();
    for (int i = 0; i < count; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ImageView || child instanceof ZoomControls) {
            child.setVisibility(View.INVISIBLE);
        }
    }
    // 隐藏比例尺
    //mMapView.showScaleControl(false);
    // 地理编码

    mGeoCoder = GeoCoder.newInstance();
    mGeoCoder.setOnGetGeoCodeResultListener(GeoListener);
    list = (ListView) findViewById(R.id.list);
    list.setOnItemClickListener(this);
    list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    loading = (ProgressBar) findViewById(R.id.loading);
    status = (TextView) findViewById(R.id.status);
    mAdapter = new MapPickerAdapter(MapPickerActivity.this, mInfoList);
    list.setAdapter(mAdapter);
}
 
Example 12
Source Project: LibreTasks   File: ActivityLogTabs.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Update the UI display
 */
private void updateUI() {
  // Update the Log List since new logs may have been created
  LogAdapter logAdapter = new LogAdapter(this);

  listView = (ListView) findViewById(R.id.activity_logs_listview);
  listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  listView.setAdapter(logAdapter);

  // Restore UI control values if possible.
  state = getSharedPreferences(KEY_STATE, Context.MODE_WORLD_READABLE
      | Context.MODE_WORLD_WRITEABLE);
  listView.setItemChecked(state.getInt(KEY_STATE_SELECTED_LOG, -1), true);
}
 
Example 13
@Override
protected View onCreateDialogView() {
	fileExplorer = new FileExplorerAdapter();
	
	LinearLayout layout = new LinearLayout(getContext());
	layout.setOrientation(LinearLayout.VERTICAL);
	
	pathTextView = new TextView(getContext());
	pathTextView.setText(fileExplorer.getCurrentPath());
	
	listView = new ListView(getContext());
	listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
	listView.setAdapter(fileExplorer);
	listView.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
			if(fileExplorer.changeDir(position)) {
				listView.setItemChecked(listView.getCheckedItemPosition(), false);
				pathTextView.setText(fileExplorer.getCurrentPath());
			}
		}
	});
	
	layout.addView(pathTextView);
	layout.addView(listView);
	return layout;
}
 
Example 14
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_page, container, false);
    ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle());

    final ListView listView = (ListView) rootView.findViewById(android.R.id.list);
    setListAdapter(new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_list_item_multiple_choice,
            android.R.id.text1,
            mChoices));
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

    // Pre-select currently selected items.
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            ArrayList<String> selectedItems = mPage.getData().getStringArrayList(
                    Page.SIMPLE_DATA_KEY);
            if (selectedItems == null || selectedItems.size() == 0) {
                return;
            }

            Set<String> selectedSet = new HashSet<String>(selectedItems);

            for (int i = 0; i < mChoices.size(); i++) {
                if (selectedSet.contains(mChoices.get(i))) {
                    listView.setItemChecked(i, true);
                }
            }
        }
    });

    return rootView;
}
 
Example 15
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item_list);

    mItemList = (ListView) findViewById(android.R.id.list);
    mDetailsFragment = (ItemDetailsFragment) getSupportFragmentManager()
            .findFragmentById(R.id.item_details);
    mIsDualFrame = mDetailsFragment != null;
    if (mIsDualFrame) {
        mItemList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        mDetailsFragment.setItemId(0);
    }
}
 
Example 16
Source Project: DropDownMenu   File: DoubleListView.java    License: Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    setOrientation(VERTICAL);
    inflate(context, R.layout.merge_filter_list, this);

    lv_left = (ListView) findViewById(R.id.lv_left);
    lv_right = (ListView) findViewById(R.id.lv_right);
    lv_left.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    lv_right.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    lv_left.setOnItemClickListener(this);
    lv_right.setOnItemClickListener(this);
}
 
Example 17
@Override
public void onCreate(Bundle savedInstanceState) {

    // CookieManager manager = CookieManager.getInstance();
    // manager.removeAllCookie();

    String action = getIntent() != null ? getIntent().getAction() : null;

    if (ACTION_OPEN_FROM_APP_INNER.equals(action)) {
        // empty
    } else if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) {
        // empty
    } else {
    }

    super.onCreate(savedInstanceState);

    setContentView(R.layout.accountactivity_layout);


    Toolbar mToolBar = (Toolbar) findViewById(R.id.accountToolBar);
    setSupportActionBar(mToolBar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolBar.setNavigationOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });


    listAdapter = new AccountAdapter();
    listView = (ListView) findViewById(R.id.listView);
    listView.setOnItemClickListener(new AccountListItemClickListener());
    listView.setAdapter(listAdapter);
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new AccountMultiChoiceModeListener());
    getLoaderManager().initLoader(LOADER_ID, null, this);

    if (SettingUtils.firstStart()) {
        showChangeLogDialog();
    }

    if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) {

        startOAuthActivity(false, null);

        AccountBean accountBean = getIntent().getParcelableExtra(REFRESH_ACTION_EXTRA);

        Toast.makeText(this, String.format(getString(R.string.account_token_has_expired), accountBean.getUsernick()),
                Toast.LENGTH_SHORT).show();

    }

}
 
Example 18
@SuppressWarnings("UnusedAssignment")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	Activity activity = getActivity();
	holder = getAttachmentHolder(EXTRA_ATTACHMENT_INDEX);
	FileHolder fileHolder = holder != null ? DraftsStorage.getInstance()
			.getAttachmentDraftFileHolder(holder.hash) : null;
	if (holder == null || fileHolder == null) {
		dismiss();
		return new Dialog(activity);
	}
	ChanConfiguration.Posting postingConfiguration = getPostingConfiguration();
	int index = 0;
	optionItems.clear();
	optionIndexes.clear();
	optionItems.add(new OptionItem(getString(R.string.text_unique_hash), OPTION_TYPE_UNIQUE_HASH,
			holder.optionUniqueHash));
	optionIndexes.append(OPTION_TYPE_UNIQUE_HASH, index++);
	if (GraphicsUtils.canRemoveMetadata(fileHolder)) {
		optionItems.add(new OptionItem(getString(R.string.text_remove_metadata), OPTION_TYPE_REMOVE_METADATA,
				holder.optionRemoveMetadata));
		optionIndexes.append(OPTION_TYPE_REMOVE_METADATA, index++);
	}
	if (fileHolder.isImage()) {
		optionItems.add(new OptionItem(getString(R.string.text_reencode_image), OPTION_TYPE_REENCODE_IMAGE,
				holder.reencoding != null));
		optionIndexes.append(OPTION_TYPE_REENCODE_IMAGE, index++);
	}
	optionItems.add(new OptionItem(getString(R.string.text_remove_file_name), OPTION_TYPE_REMOVE_FILE_NAME,
			holder.optionRemoveFileName));
	optionIndexes.append(OPTION_TYPE_REMOVE_FILE_NAME, index++);
	if (postingConfiguration.attachmentSpoiler) {
		optionItems.add(new OptionItem(getString(R.string.text_spoiler), OPTION_TYPE_SPOILER,
				holder.optionSpoiler));
		optionIndexes.append(OPTION_TYPE_SPOILER, index++);
	}
	ArrayList<String> items = new ArrayList<>();
	for (OptionItem optionItem : optionItems) {
		items.add(optionItem.title);
	}
	LinearLayout linearLayout = new LinearLayout(activity);
	linearLayout.setOrientation(LinearLayout.VERTICAL);
	ImageView imageView = new ImageView(activity);
	imageView.setBackground(new TransparentTileDrawable(activity, true));
	imageView.setImageDrawable(holder.imageView.getDrawable());
	imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
	linearLayout.addView(imageView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
	listView = new ListView(activity);
	linearLayout.addView(listView, LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
	int resId = ResourceUtils.obtainAlertDialogLayoutResId(activity, ResourceUtils.DIALOG_LAYOUT_MULTI_CHOICE);
	if (C.API_LOLLIPOP) {
		listView.setDividerHeight(0);
	}
	ItemsAdapter adapter = new ItemsAdapter(activity, resId, items);
	listView.setAdapter(adapter);
	for (int i = 0; i < optionItems.size(); i++) {
		listView.setItemChecked(i, optionItems.get(i).checked);
	}
	listView.setOnItemClickListener(this);
	updateItemsEnabled(adapter, holder);
	AlertDialog dialog = new AlertDialog.Builder(activity).setView(linearLayout).create();
	dialog.setCanceledOnTouchOutside(true);
	return dialog;
}
 
Example 19
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main_container);
	RootTools.debugMode = false;
	
	boolean access = RootTools.isAccessGiven();
	boolean busybox = RootTools.isBusyboxAvailable();
	if(!access) {
		showRootWarning();
	}
	if(!busybox) {
		showBusyBoxWarning();
	}
	
	mContainer = (FrameLayout) findViewById(R.id.activity_container);
	mContext = this;
	mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
	getActionBar().setDisplayHomeAsUpEnabled(true);
	getActionBar().setHomeButtonEnabled(true);
	View v = this.getLayoutInflater().inflate(R.layout.menu_list, null, false);
	menulist = (ListView) v.findViewById(R.id.navbarlist);
	db = new DatabaseHandler(this);
	vddDb = new VddDatabaseHandler(this);

	menu = new SlidingMenu(this);
	menu.setMode(SlidingMenu.LEFT_RIGHT);
	menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
	menu.setShadowWidthRes(R.dimen.shadow_width);
	menu.setShadowDrawable(R.drawable.shadow);
	//menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
	menu.setBehindWidthRes(R.dimen.slidingmenu_offset);
	menu.setFadeDegree(0.35f);
	menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
	menu.setMenu(v);
	View vv = this.getLayoutInflater().inflate(R.layout.menu_glossary, null, false);
	mGlossaryContainer = (FrameLayout) vv.findViewById(R.id.menu_frame);
	menu.setSecondaryMenu(vv);
	menu.setSecondaryShadowDrawable(R.drawable.shadow_right);

	mAdapter = new CustomArrayAdapter(
			this,
			R.layout.menu_main_list_item,
			getResources().getStringArray(R.array.menu_entries), 
			getResources().getStringArray(R.array.menu_descs),
			getResources().getStringArray(R.array.menu_colors),
			icons);
	menulist.setAdapter(mAdapter);
	menulist.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
	menulist.setOnItemClickListener(this);

	colors = getResources().getStringArray(R.array.menu_colors);

	FragmentTransaction ft = getFragmentManager().beginTransaction();
	Fragment prefs = new TimeInState();
	CpuGlossaryFragment glo = new CpuGlossaryFragment();
	ft.replace(R.id.activity_container,prefs);
	ft.replace(R.id.menu_frame, glo);
	ft.commit();

	
	setAppTheme();
	mountPartitions();
	copyHelpers();
}
 
Example 20
Source Project: 365browser   File: ItemChooserDialog.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates the ItemChooserPopup and displays it (and starts waiting for data).
 *
 * @param activity Activity which is used for launching a dialog.
 * @param callback The callback used to communicate back what was selected.
 * @param labels The labels to show in the dialog.
 */
public ItemChooserDialog(
        Activity activity, ItemSelectedCallback callback, ItemChooserLabels labels) {
    mActivity = activity;
    mItemSelectedCallback = callback;
    mLabels = labels;

    LinearLayout dialogContainer = (LinearLayout) LayoutInflater.from(mActivity).inflate(
            R.layout.item_chooser_dialog, null);

    mListView = (ListView) dialogContainer.findViewById(R.id.items);
    mProgressBar = (ProgressBar) dialogContainer.findViewById(R.id.progress);
    mStatus = (TextView) dialogContainer.findViewById(R.id.status);
    mTitle = (TextViewWithClickableSpans) dialogContainer.findViewById(
            R.id.dialog_title);
    mEmptyMessage =
            (TextViewWithClickableSpans) dialogContainer.findViewById(R.id.not_found_message);

    mTitle.setText(labels.title);
    mTitle.setMovementMethod(LinkMovementMethod.getInstance());

    mEmptyMessage.setMovementMethod(LinkMovementMethod.getInstance());
    mStatus.setMovementMethod(LinkMovementMethod.getInstance());

    mConfirmButton = (Button) dialogContainer.findViewById(R.id.positive);
    mConfirmButton.setText(labels.positiveButton);
    mConfirmButton.setEnabled(false);
    mConfirmButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mItemSelectedCallback.onItemSelected(mItemAdapter.getSelectedItemKey());
            mDialog.setOnDismissListener(null);
            mDialog.dismiss();
        }
    });

    mItemAdapter = new ItemAdapter(mActivity, R.layout.item_chooser_dialog_row);
    mItemAdapter.setNotifyOnChange(true);
    mListView.setAdapter(mItemAdapter);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mListView.setEmptyView(mEmptyMessage);
    mListView.setOnItemClickListener(mItemAdapter);
    mListView.setDivider(null);
    setState(State.STARTING);

    // The list is the main element in the dialog and it should grow and
    // shrink according to the size of the screen available.
    View listViewContainer = dialogContainer.findViewById(R.id.container);
    listViewContainer.setLayoutParams(new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT,
            getListHeight(mActivity.getWindow().getDecorView().getHeight(),
                    mActivity.getResources().getDisplayMetrics().density)));

    mIgnorePendingWindowFocusChangeForClose = false;

    showDialogForView(dialogContainer);
}