Example usage for android.widget ListView getCheckedItemPositions

List of usage examples for android.widget ListView getCheckedItemPositions

Introduction

In this page you can find the example usage for android.widget ListView getCheckedItemPositions.

Prototype

public SparseBooleanArray getCheckedItemPositions() 

Source Link

Document

Returns the set of checked items in the list.

Usage

From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java

/**
 * Function to set the answer types that will be present in the test
 *//*  www.  j  av  a2  s  . com*/
private void setAnswerTypes() {
    ListView checkBoxesList = (ListView) findViewById(R.id.testAnswerTypesList);
    AnswerTypesArrayAdapter answerTypesAdapter = (AnswerTypesArrayAdapter) checkBoxesList.getAdapter();
    int childsCount = checkBoxesList.getCount();
    SparseBooleanArray checkedItems = checkBoxesList.getCheckedItemPositions();
    answerTypesList = new ArrayList<String>();

    /*
       * If "All tags" item checked, add the whole list to the list of selected answer types,
     * else, add the selected items to the list of selected answer types
     */
    if (checkedItems.get(0, false)) {
        answerTypesList.add("all");
    } else {
        for (int i = 1; i < childsCount; i++) {
            if (checkedItems.get(i, false)) {
                answerTypesList.add((String) answerTypesAdapter.getItem(i));
            }
        }
    }

    if (isDebuggable) {
        Log.d(TAG, "answerTypesList=" + answerTypesList.toString());
    }

    //If no answer types selected, show a message to notice user
    if (answerTypesList.isEmpty()) {
        Toast.makeText(getApplicationContext(), R.string.testNoAnswerTypesSelectedMsg, Toast.LENGTH_LONG)
                .show();

        //If any answer type is selected, generate the test and show the first question screen
    } else {
        makeTest();
    }
}

From source file:com.Candy.sizer.CandySizer.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final ImageView delButton = (ImageView) getView().findViewById(R.id.btn_delete);
    final ImageView profileButton = (ImageView) getView().findViewById(R.id.btn_profile);

    if (delButton == null) {
        return;//from ww  w  .  jav  a 2  s . c  om
    }

    // create arraylist of apps not to be removed
    final ArrayList<String> safetyList = new ArrayList<String>();
    safetyList.add("BackupRestoreConfirmation.apk");
    safetyList.add("CertInstaller.apk");
    safetyList.add("Contacts.apk");
    safetyList.add("ContactsProvider.apk");
    safetyList.add("DefaultContainerService.apk");
    safetyList.add("DownloadProvider.apk");
    safetyList.add("DrmProvider.apk");
    safetyList.add("MediaProvider.apk");
    safetyList.add("Mms.apk");
    safetyList.add("PackageInstaller.apk");
    safetyList.add("Phone.apk");
    safetyList.add("Settings.apk");
    safetyList.add("SettingsProvider.apk");
    safetyList.add("CandyOTA.apk");
    safetyList.add("Superuser.apk");
    safetyList.add("SystemUI.apk");
    safetyList.add("TelephonyProvider.apk");

    // create arraylist from /system/app content
    File system = new File(systemPath);
    String[] sysappArray = system.list();
    mSysApp = new ArrayList<String>(Arrays.asList(sysappArray));

    // remove "apps not to be removed" from list and sort list
    mSysApp.removeAll(safetyList);
    Collections.sort(mSysApp);

    // populate listview via arrayadapter
    adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_multiple_choice,
            mSysApp);

    final ListView lv = (ListView) getView().findViewById(R.string.listsystem);
    lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    lv.setAdapter(adapter);

    // longclick an entry
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) {
            // create deletion dialog
            String item = lv.getAdapter().getItem(arg2).toString();
            showDialog(DELETE_DIALOG, item, adapter, 0);
            return false;
        }
    });
    // click button delete
    delButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // check which items are selected
            String item = null;
            int itemCounter = 0;
            SparseBooleanArray checked = lv.getCheckedItemPositions();
            for (int i = lv.getCount() - 1; i > 0; i--) {
                if (checked.get(i)) {
                    item = mSysApp.get(i);
                    itemCounter++;
                }
            }
            if (item == null) {
                toast(getResources().getString(R.string.sizer_message_noselect));
                return;
            } else {
                showDialog(DELETE_MULTIPLE_DIALOG, item, adapter, itemCounter);
            }
        }
    });
    // click button profile
    profileButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // call select dialog
            selectDialog(mSysApp, adapter);
        }
    });
}

From source file:com.github.jvanhie.discogsscrobbler.NowPlayingFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setSelection(final ListView list) {
    list.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    list.setSelector(R.drawable.track_selector);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override//from  w  w w .  j  a  va  2 s.c o m
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (mBound) {
                //fully stop previous playlist since we start again from the beginning of the selected track
                ArrayList<Track> trackList = new ArrayList<Track>(mService.trackList);
                mService.stop();
                mService.trackList = trackList;
                mService.currentTrack = i;
                mService.resume();
            }
        }
    });
    list.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
        @Override
        public void onItemCheckedStateChanged(ActionMode actionMode, int i, long l, boolean b) {

        }

        @Override
        public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
            MenuInflater inflater = getActivity().getMenuInflater();
            inflater.inflate(R.menu.now_playing_cab, menu);
            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
            SparseBooleanArray checkedItems = list.getCheckedItemPositions();
            final List<Integer> positions = new ArrayList<Integer>();
            if (checkedItems != null) {
                for (int i = 0; i < checkedItems.size(); i++) {
                    if (checkedItems.valueAt(i)) {
                        positions.add(checkedItems.keyAt(i));
                    }
                }
            }
            switch (menuItem.getItemId()) {
            case R.id.play_selection:
                if (mBound) {
                    //change tracklist and start over again
                    ArrayList<Track> newTrackList = new ArrayList<Track>();
                    for (Integer i : positions) {
                        newTrackList.add(mService.trackList.get(i));
                    }
                    //fully stop previous playlist since we start again from the beginning
                    mService.stop();
                    mService.trackList = newTrackList;
                    mService.currentTrack = 0;
                    mService.resume();
                }
                actionMode.finish();
                break;
            case R.id.remove_selection:
                int currPlaying = mService.currentTrack;
                int newPlaying = -1;
                //change tracklist and start over again
                ArrayList<Track> newTrackList = new ArrayList<Track>();
                for (int i = 0; i < mService.trackList.size(); i++) {
                    if (!positions.contains(i)) {
                        newTrackList.add(mService.trackList.get(i));
                    }
                    //calculate new currently playing counter
                    if (i == currPlaying) {
                        if (positions.contains(i)) {
                            currPlaying++;
                        } else {
                            newPlaying = newTrackList.size() - 1;
                        }
                    }
                }
                //the currently playing track was removed, start fresh from the next available
                if (currPlaying != mService.currentTrack) {
                    mService.stop();
                    if (newPlaying != -1) {
                        mService.trackList = newTrackList;
                        mService.currentTrack = newPlaying;
                        mService.resume();
                    }
                } else {
                    //pause the playlist and resume with the new tracklist
                    mService.pause();
                    mService.trackList = newTrackList;
                    mService.currentTrack = newPlaying;
                    mService.resume();
                }
                actionMode.finish();
                break;
            }
            return false;
        }

        @Override
        public void onDestroyActionMode(ActionMode actionMode) {

        }
    });
}

From source file:cat.wuyingren.rorhelper.fragments.GameListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    dataSource = new GameDataSource(getActivity());
    dataSource.open();/*from   ww w.  j  a  va  2  s.  c  o m*/

    values = dataSource.getAllGames();

    adapter = new MultipleRowAdapter(getActivity(), values);

    setListAdapter(adapter);

    final ListView listView = getListView();
    listView.setItemsCanFocus(false);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new ListView.MultiChoiceModeListener() {

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            // Here you can do something when items are selected/de-selected,
            // such as update the title in the CAB
            //mode.setTag();
            int selectionColor = getResources().getColor(R.color.colorPrimary);
            Log.w("TAG", "onItemCheckedStateChanged() " + checked + " " + position);
            mode.setSubtitle(listView.getCheckedItemCount() + " selected");
            if (checked) {
                listView.getChildAt(position).setBackgroundColor(selectionColor);
            } else {
                listView.getChildAt(position)
                        .setBackgroundColor(getResources().getColor(android.R.color.transparent));
            }
        }

        @Override
        public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
            // Inflate the menu for the CAB

            Log.w("TAG", "onCreateActionMode");
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.menu_context, menu);
            mode.setTitle(getString(R.string.action_choose));
            return true;
        }

        @Override
        public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) {
            // Here you can perform updates to the CAB due to
            // an invalidate() request
            return false;
        }

        @Override
        public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) {
            // Respond to clicks on the actions in the CAB

            switch (item.getItemId()) {
            case R.id.action_delete:
                deleteItems(listView.getCheckedItemPositions());
                mode.finish();
                return true;
            default:
                return false;
            }
        }

        @Override
        public void onDestroyActionMode(android.view.ActionMode mode) {
            // Here you can make any necessary updates to the activity when
            // the CAB is removed. By default, selected items are deselected/unchecked.

            SparseBooleanArray checked = listView.getCheckedItemPositions();
            for (int i = 0; i < listView.getAdapter().getCount(); i++) {
                if (checked.get(i)) {
                    listView.getChildAt(i)
                            .setBackgroundColor(getResources().getColor(android.R.color.transparent));
                }
            }
        }

    });
    // dataSource.close();
}

From source file:org.mozilla.gecko.GeckoApp.java

/**
 * @param aPermissions/*from  www .j  ava 2  s  . co m*/
 *        Array of JSON objects to represent site permissions.
 *        Example: { type: "offline-app", setting: "Store Offline Data: Allow" }
 */
private void showSiteSettingsDialog(String aHost, JSONArray aPermissions) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);

    View customTitleView = getLayoutInflater().inflate(R.layout.site_setting_title, null);
    ((TextView) customTitleView.findViewById(R.id.title)).setText(R.string.site_settings_title);
    ((TextView) customTitleView.findViewById(R.id.host)).setText(aHost);
    builder.setCustomTitle(customTitleView);

    // If there are no permissions to clear, show the user a message about that.
    // In the future, we want to disable the menu item if there are no permissions to clear.
    if (aPermissions.length() == 0) {
        builder.setMessage(R.string.site_settings_no_settings);
    } else {
        // Eventually we should use a list adapter and custom checkable list items
        // to make a two-line UI to match the mock-ups
        CharSequence[] items = new CharSequence[aPermissions.length()];
        boolean[] states = new boolean[aPermissions.length()];
        for (int i = 0; i < aPermissions.length(); i++) {
            try {
                items[i] = aPermissions.getJSONObject(i).getString("setting");
                // Make all the items checked by default
                states[i] = true;
            } catch (JSONException e) {
                Log.i(LOGTAG, "JSONException: " + e);
            }
        }
        builder.setMultiChoiceItems(items, states, new DialogInterface.OnMultiChoiceClickListener() {
            public void onClick(DialogInterface dialog, int item, boolean state) {
                // Do nothing
            }
        });
        builder.setPositiveButton(R.string.site_settings_clear, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                ListView listView = ((AlertDialog) dialog).getListView();
                SparseBooleanArray checkedItemPositions = listView.getCheckedItemPositions();

                // An array of the indices of the permissions we want to clear
                JSONArray permissionsToClear = new JSONArray();
                for (int i = 0; i < checkedItemPositions.size(); i++) {
                    boolean checked = checkedItemPositions.get(i);
                    if (checked)
                        permissionsToClear.put(i);
                }
                GeckoAppShell.sendEventToGecko(
                        GeckoEvent.createBroadcastEvent("Permissions:Clear", permissionsToClear.toString()));
            }
        });
    }

    builder.setNegativeButton(R.string.site_settings_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

    mMainHandler.post(new Runnable() {
        public void run() {
            builder.create().show();
        }
    });
}

From source file:net.kazzz.NFCTagWriter.java

/**
 * ISO15693 Tag????????//from  www .j  av  a  2 s  . co m
 * 
 * 
 * @param btnWrite ?????
 * @param editWrite ??
 * @param listMemBlock?
 * @param useNDEFNDEF????
 */
private void prepareISO15693(final Button btnWrite, final EditText editWrite, final ListView listMemBlock) {
    final CheckBox chkUseNDEF = (CheckBox) findViewById(R.id.chk_useNDEF);

    //??
    ISO15693Tag ft = new ISO15693Tag(this.mNfcTag);
    try {
        SystemInformationResponse sysInfo = ft.getSystemInformation();
        if (sysInfo == null || sysInfo.hasError()) {
            throw new ISO15693Exception(
                    "ISO15693 ??????????? : "
                            + sysInfo.getErrorCode());
        }

        final MemorySizeInfo memInfo = sysInfo.getMemoryInfo();
        if (memInfo == null || memInfo.getNumberOfBlocks() == 0) {
            throw new ISO15693Exception("ISO15693 ?????????");
        }

        chkUseNDEF.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                listMemBlock.setEnabled(!chkUseNDEF.isChecked());
                listMemBlock.setClickable(!chkUseNDEF.isChecked());
                //NDEF??NDEF?????
                if (chkUseNDEF.isChecked()) {
                    btnWrite.setEnabled(true);
                    editWrite.setEnabled(true);
                    //NDEF????10byte?
                    editWrite.setHint((memInfo.getBlockSize() * memInfo.getNumberOfBlocks()) - 10
                            + "??");
                } else {
                    if (editWrite.getText().length() > 0) {
                        btnWrite.setEnabled(true);
                        editWrite.setEnabled(true);
                    } else {
                        btnWrite.setEnabled(false);
                        editWrite.setEnabled(false);
                    }
                    editWrite.setHint(memInfo.getBlockSize() + "??");
                }
            }
        });

        ReadMultipleBlocksResponse rbResp = ft.readMultipleBlocks((byte) 0, memInfo.getBlockSize(),
                memInfo.getNumberOfBlocks());
        if (rbResp == null || rbResp.hasError()) {
            throw new ISO15693Exception(
                    "ISO15693 ReadMultipleBlock?????" + sysInfo.getErrorCode());
        }

        //??????
        ViewHolder[] holders = new ViewHolder[memInfo.getNumberOfBlocks()];
        for (byte i = 0; i < memInfo.getNumberOfBlocks(); i++) {
            BlockData bd = rbResp.getBlockDatas()[i];

            ViewHolder holder = new ViewHolder();
            holder.blockName = "block " + i;
            holder.isWritable = !bd.isLocked();
            holder.accessMode = bd.isLocked() ? "(Lock)" : "(UnLock)";

            //??
            if (bd.getData() != null && bd.getData().length > 0) {
                holder.data = bd.getData();
            } else {
                holder.data = new byte[memInfo.getBlockSize()];
                for (int b = 0; b < holder.data.length; b++) {
                    holder.data[b] = 0x00; //??
                }
            }
            holders[i] = holder;
        }
        final LayoutInflater layoutInflater = (LayoutInflater) this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        //ArrayAdapter? (??
        ArrayAdapter<ViewHolder> adapter = new ArrayAdapter<ViewHolder>(this,
                android.R.layout.simple_list_item_multiple_choice, holders) {

            /* (non-Javadoc)
             * @see android.widget.BaseAdapter#isEnabled(int)
             */
            @Override
            public boolean isEnabled(int position) {
                SparseBooleanArray arry = listMemBlock.getCheckedItemPositions();
                if (arry.indexOfValue(true) != -1 && !arry.get(position) //??????? 
                        && (!arry.get(position - 1) && !arry.get(position + 1))) //????? 
                {
                    //???????
                    return false;
                }
                return super.isEnabled(position);
            }

            /* (non-Javadoc)
             * @see android.widget.ArrayAdapter#getView(int, android.view.View, android.view.ViewGroup)
             */
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {

                if (null == convertView) {
                    convertView = layoutInflater.inflate(android.R.layout.simple_list_item_multiple_choice,
                            null);
                }

                ViewHolder holder = this.getItem(position);

                if (holder != null) {

                    StringBuilder sb = new StringBuilder();
                    sb.append(holder.blockName).append(" ").append(holder.accessMode).append("\n");
                    if (holder.data != null && holder.data.length > 0) {
                        //UTF-8?
                        Charset utfEncoding = Charset.forName("UTF-8");
                        sb.append(" : ").append(new String(holder.data, utfEncoding).trim());
                    }
                    ((TextView) convertView).setText(sb.toString());
                }
                return convertView;
            }

        };

        listMemBlock.setAdapter(adapter);

        // ?????  
        //listMemBlock.setItemsCanFocus(false);  
        //?
        listMemBlock.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

        listMemBlock.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                //?????
                SparseBooleanArray arry = listMemBlock.getCheckedItemPositions();

                ByteBuffer buff = ByteBuffer.allocate(arry.size() * memInfo.getBlockSize());
                int writableBlockCount = 0;
                for (int i = 0; i < arry.size(); i++) {
                    int key = arry.keyAt(i);
                    //?????
                    Object o = parent.getItemAtPosition(key);
                    if (o != null && o instanceof ViewHolder) {
                        ViewHolder holder = (ViewHolder) o;
                        if (holder.isWritable) {
                            writableBlockCount++;
                            if (holder.data != null && holder.data.length > 0) {
                                buff.put(holder.data);
                            }
                        }
                    }
                }
                //UTF-8?
                StringBuilder sb = new StringBuilder();
                Charset utfEncoding = Charset.forName("UTF-8");
                sb.append(new String(buff.array(), utfEncoding).trim());

                editWrite.setHint(memInfo.getBlockSize() * writableBlockCount + "??");

                if (writableBlockCount > 0) {
                    editWrite.setText(sb.toString().trim());
                    editWrite.setTag(arry);
                    //????????????
                    btnWrite.setEnabled(true);
                    editWrite.setEnabled(true);
                } else {
                    btnWrite.setEnabled(false);
                    editWrite.setEnabled(false);
                }

            }
        });
    } catch (ISO15693Exception e) {
        e.printStackTrace();
        Log.e(TAG, e.toString());
    }
}

From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java

public void selectRemoteShareDlg(final String remurl, String remdir, final NotifyEvent p_ntfy) {

    NotifyEvent ntfy = new NotifyEvent(mContext);
    // set thread response 
    ntfy.setListener(new NotifyEventListener() {
        @Override/*w  ww. j  a  v  a  2s  . co  m*/
        public void positiveResponse(Context c, Object[] o) {
            final ArrayList<String> rows = new ArrayList<String>();
            @SuppressWarnings("unchecked")
            ArrayList<TreeFilelistItem> rfl = (ArrayList<TreeFilelistItem>) o[0];

            for (int i = 0; i < rfl.size(); i++) {
                if (rfl.get(i).isDir() && rfl.get(i).canRead() && !rfl.get(i).getName().endsWith("$"))
                    //                     !rfl.get(i).getName().startsWith("IPC$"))
                    rows.add(rfl.get(i).getName().replaceAll("/", ""));
            }
            boolean wk_list_empty = false;
            if (rows.size() < 1) {
                wk_list_empty = true;
                rows.add(mContext.getString(R.string.msgs_dir_empty));
            }
            final boolean list_empty = wk_list_empty;
            Collections.sort(rows, String.CASE_INSENSITIVE_ORDER);
            //??
            final Dialog dialog = new Dialog(mContext);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(false);
            dialog.setContentView(R.layout.item_select_list_dlg);

            LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.item_select_list_dlg_view);
            ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color);

            final LinearLayout title_view = (LinearLayout) dialog
                    .findViewById(R.id.item_select_list_dlg_title_view);
            final TextView title = (TextView) dialog.findViewById(R.id.item_select_list_dlg_title);
            final TextView subtitle = (TextView) dialog.findViewById(R.id.item_select_list_dlg_subtitle);
            title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color);
            title.setTextColor(mGp.themeColorList.text_color_dialog_title);
            subtitle.setTextColor(mGp.themeColorList.text_color_dialog_title);

            title.setText(mContext.getString(R.string.msgs_select_remote_share));
            subtitle.setVisibility(TextView.GONE);

            //              if (rows.size()<=2) 
            //                 ((TextView)dialog.findViewById(R.id.item_select_list_dlg_spacer))
            //                 .setVisibility(TextView.VISIBLE);
            final Button btn_cancel = (Button) dialog.findViewById(R.id.item_select_list_dlg_cancel_btn);
            final Button btn_ok = (Button) dialog.findViewById(R.id.item_select_list_dlg_ok_btn);
            btn_ok.setEnabled(false);

            CommonDialog.setDlgBoxSizeLimit(dialog, false);

            final ListView lv = (ListView) dialog.findViewById(android.R.id.list);
            if (!list_empty) {
                lv.setAdapter(
                        new ArrayAdapter<String>(mContext, R.layout.custom_simple_list_item_checked, rows));
                //  android.R.layout.simple_list_item_checked,rows));
                lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            } else {
                lv.setAdapter(new ArrayAdapter<String>(mContext, R.layout.simple_list_item_1o, rows));
            }
            lv.setScrollingCacheEnabled(false);
            lv.setScrollbarFadingEnabled(false);

            lv.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
                    if (rows.get(idx).startsWith("---"))
                        return;
                    if (!list_empty)
                        btn_ok.setEnabled(true);
                }
            });
            //CANCEL?
            btn_cancel.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dialog.dismiss();
                    p_ntfy.notifyToListener(false, null);
                }
            });
            //OK?
            btn_ok.setVisibility(Button.VISIBLE);
            btn_ok.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    dialog.dismiss();
                    SparseBooleanArray checked = lv.getCheckedItemPositions();
                    for (int i = 0; i <= rows.size(); i++) {
                        if (checked.get(i) == true) {
                            p_ntfy.notifyToListener(true, new Object[] { rows.get(i) });
                            break;
                        }
                    }
                }
            });
            // Cancel?
            dialog.setOnCancelListener(new Dialog.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface arg0) {
                    btn_cancel.performClick();
                }
            });
            //            dialog.setOnKeyListener(new DialogOnKeyListener(context));
            //            dialog.setCancelable(false);
            dialog.show();
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            p_ntfy.notifyToListener(false, o);
        }
    });
    createRemoteFileList(remurl, remdir, ntfy, false);

}