Example usage for android.widget EditText setSelection

List of usage examples for android.widget EditText setSelection

Introduction

In this page you can find the example usage for android.widget EditText setSelection.

Prototype

public void setSelection(int start, int stop) 

Source Link

Document

Convenience for Selection#setSelection(Spannable,int,int) .

Usage

From source file:cgeo.geocaching.cgBase.java

/**
 * insert text into the EditText at the current cursor position
 *
 * @param editText//  w ww  .  j  a v a  2s.com
 * @param insertText
 * @param addSpace
 *            add a space character, if there is no whitespace before the current cursor position
 * @param moveCursor
 *            place the cursor after the inserted text
 */
static void insertAtPosition(final EditText editText, String insertText, final boolean addSpace,
        final boolean moveCursor) {
    int selectionStart = editText.getSelectionStart();
    int selectionEnd = editText.getSelectionEnd();
    int start = Math.min(selectionStart, selectionEnd);
    int end = Math.max(selectionStart, selectionEnd);

    String content = editText.getText().toString();
    if (start > 0 && !Character.isWhitespace(content.charAt(start - 1))) {
        insertText = " " + insertText;
    }

    editText.getText().replace(start, end, insertText);
    int newCursor = moveCursor ? start + insertText.length() : start;
    editText.setSelection(newCursor, newCursor);
}

From source file:com.sentaroh.android.Utilities.Dialog.FileSelectDialogFragment.java

private void initViewWidget() {
    if (mDebugEnable)
        Log.v(APPLICATION_TAG, "initViewWidget");

    if (mDebugEnable)
        Log.v(APPLICATION_TAG, "Create=" + mDialogEnableCreate + ", Title=" + mDialogTitle + ", lurl="
                + mDialogLocalUrl + ", ldir=" + mDialogLocalDir + ", file name=" + mDialogFileName);

    mThemeColorList = ThemeUtil.getThemeColorList(getActivity());

    mDialog.setContentView(R.layout.file_select_edit_dlg);
    LinearLayout title_view = (LinearLayout) mDialog.findViewById(R.id.file_select_edit_dlg_title_view);
    title_view.setBackgroundColor(mThemeColorList.dialog_title_background_color);
    TextView title = (TextView) mDialog.findViewById(R.id.file_select_edit_dlg_title);
    title.setTextColor(mThemeColorList.text_color_dialog_title);
    title.setText(mDialogTitle);//from   ww  w. j a  v  a2  s .  c  o m
    final TextView dlg_msg = (TextView) mDialog.findViewById(R.id.file_select_edit_dlg_msg);
    final Button btnHome = (Button) mDialog.findViewById(R.id.file_select_edit_dlg_home_dir_btn);
    btnHome.setTextColor(mThemeColorList.text_color_primary);
    btnHome.setVisibility(Button.VISIBLE);
    final Button btnCreate = (Button) mDialog.findViewById(R.id.file_select_edit_dlg_create_btn);
    btnCreate.setTextColor(mThemeColorList.text_color_primary);
    final Button btnOk = (Button) mDialog.findViewById(R.id.file_select_edit_dlg_ok_btn);
    //      btnOk.setTextColor(mThemeColorList.text_color_primary);
    final Button btnCancel = (Button) mDialog.findViewById(R.id.file_select_edit_dlg_cancel_btn);
    btnCancel.setTextColor(mThemeColorList.text_color_primary);
    final Button btnRefresh = (Button) mDialog.findViewById(R.id.file_select_edit_dlg_refresh_btn);
    btnRefresh.setTextColor(mThemeColorList.text_color_primary);

    LinearLayout ll_dlg_view = (LinearLayout) mDialog.findViewById(R.id.file_select_edit_dlg_view);
    ll_dlg_view.setBackgroundColor(mThemeColorList.dialog_msg_background_color);

    final Activity activity = getActivity();
    final Context context = activity.getApplicationContext();

    if (mDialogEnableCreate) {
        btnCreate.setVisibility(TextView.VISIBLE);
    }

    mLocalMountPointSpinner = (Spinner) mDialog.findViewById(R.id.file_select_edit_dlg_rdir);
    setSpinnerBackground(context, mLocalMountPointSpinner, mThemeColorList.theme_is_light);
    mLocalMountPointSpinner.setVisibility(Spinner.VISIBLE);
    //   Root directory spinner
    CustomSpinnerAdapter adapter = new CustomSpinnerAdapter(activity, R.layout.custom_simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mLocalMountPointSpinner.setPrompt(context.getString(R.string.msgs_file_select_edit_local_mount_point));
    mLocalMountPointSpinner.setAdapter(adapter);

    int a_no = -1;
    ArrayList<String> ml = LocalMountPoint.getLocalMountPointList(context);
    mLocalMountPointSpinner.setOnItemSelectedListener(null);
    if (mDialogMpLimitInternalAndSdcard) {
        adapter.add(Environment.getExternalStorageDirectory().toString());
        File[] fl = ContextCompat.getExternalFilesDirs(context, null);
        for (File item : fl) {
            if (!item.getPath().startsWith(Environment.getExternalStorageDirectory().toString())) {
                adapter.add(item.getPath().substring(0, item.getPath().indexOf("/Android")));
                break;
            }
        }
        mLocalMountPointSpinner.setEnabled(true);
        for (int i = 0; i < adapter.getCount(); i++) {
            if (adapter.getItem(i).equals(mDialogLocalUrl)) {
                a_no = i;
                break;
            }
        }
        mLocalMountPointSpinner.setSelection(a_no);
    } else {
        if (ml.size() == 0) {
            if (mDialogIncludeRoot)
                adapter.add("/");
            adapter.add(mDialogLocalUrl);
            mLocalMountPointSpinner.setEnabled(false);
        } else {
            mLocalMountPointSpinner.setEnabled(true);
            if (mDialogIncludeRoot)
                adapter.add("/");
            for (int i = 0; i < ml.size(); i++)
                adapter.add(ml.get(i));
            for (int i = 0; i < ml.size(); i++) {
                if (mDialogLocalUrl.startsWith(ml.get(i))) {
                    a_no = i;
                    break;
                }
            }
            mLocalMountPointSpinner.setSelection(a_no);
        }
    }
    LinearLayout ll_mp = (LinearLayout) mDialog.findViewById(R.id.file_select_edit_dlg_mp_view);
    if (mDialogHideMp)
        ll_mp.setVisibility(LinearLayout.GONE);
    else
        ll_mp.setVisibility(LinearLayout.VISIBLE);
    //      ll_mp.setVisibility(LinearLayout.GONE);

    //   final TextView v_spacer=(TextView)mDialog.findViewById(R.id.file_select_edit_dlg_spacer);
    mTreeFileListView = (ListView) mDialog.findViewById(android.R.id.list);
    final CustomTextView dir_name = (CustomTextView) mDialog.findViewById(R.id.file_select_edit_dlg_dir_name);
    dir_name.setTextColor(mThemeColorList.text_color_primary);
    final EditText file_name = (EditText) mDialog.findViewById(R.id.file_select_edit_dlg_file_name);
    if (!mDialogSingleSelect)
        file_name.setVisibility(EditText.GONE);
    else
        file_name.setVisibility(EditText.VISIBLE);
    if (mDialogFileOnly) {
        file_name.setVisibility(EditText.VISIBLE);
        file_name.setEnabled(true);
        dir_name.setVisibility(EditText.VISIBLE);
    } else {
        if (mDialogDirectoryOnly) {
            file_name.setVisibility(EditText.GONE);
            file_name.setEnabled(false);
            dir_name.setVisibility(EditText.VISIBLE);
            btnHome.setVisibility(EditText.VISIBLE);
        } else {
            file_name.setVisibility(EditText.VISIBLE);
            file_name.setEnabled(true);
            dir_name.setVisibility(EditText.VISIBLE);
            btnHome.setVisibility(EditText.VISIBLE);
        }
    }
    file_name.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View arg0, int keyCode, KeyEvent event) {
            if (//event.getAction() == KeyEvent.ACTION_DOWN &&
            keyCode == KeyEvent.KEYCODE_ENTER) {
                return true;
            }
            return false;
        }
    });
    //    if (dirs.size()<=2)   v_spacer.setVisibility(TextView.VISIBLE);

    mTreeFilelistAdapter = new TreeFilelistAdapter(activity, mDialogSingleSelect, true);
    mTreeFileListView.setAdapter(mTreeFilelistAdapter);

    if (mDialogLocalUrl.equals(""))
        mDialogLocalUrl = ml.get(0);
    ArrayList<TreeFilelistItem> tfl = createLocalFilelist(mDialogFileOnly, mDialogLocalUrl, "");
    if (tfl.size() == 0) {
        tfl.add(new TreeFilelistItem(context.getString(R.string.msgs_file_select_edit_dir_empty)));
    } else {
        mTreeFilelistAdapter.setDataList(tfl);
        if (!mDialogLocalDir.equals("")) {
            String sel_dir = mDialogLocalDir;
            String n_dir = "", e_dir = "";
            if (sel_dir.startsWith("/"))
                n_dir = sel_dir.substring(1);
            else
                n_dir = sel_dir;
            if (n_dir.endsWith("/"))
                e_dir = n_dir.substring(0, n_dir.length() - 1);
            else
                e_dir = n_dir;
            //              Log.v("","mp="+mDialogLocalUrl+", se;_dir="+sel_dir+", e_dir="+e_dir);
            selectLocalDirTree(e_dir);
        }
        if (!mDialogFileName.equals(""))
            selectLocalDirTreeFile(mDialogFileName);
    }
    mTreeFileListView.setScrollingCacheEnabled(false);
    mTreeFileListView.setScrollbarFadingEnabled(false);

    if (mSavedViewContentsValue != null && mSavedViewContentsValue.mainDialogFilename != null) {
        file_name.setText(mSavedViewContentsValue.mainDialogFilename);
        file_name.setSelection(mSavedViewContentsValue.mainDialogFilenameSelStart,
                mSavedViewContentsValue.mainDialogFilenameTextSelEnd);
        dir_name.setText(mSavedViewContentsValue.mainDialogDirName);
    } else {
        String d_name = mDialogLocalDir.equals("") ? mDialogLocalUrl + "/"
                : mDialogLocalUrl + mDialogLocalDir + "/";
        dir_name.setText(d_name);
        file_name.setText(mDialogFileName);
    }

    if (!mDialogSingleSelect)
        btnOk.setEnabled(false);

    NotifyEvent cb_ntfy = new NotifyEvent(context);
    // set file list thread response listener 
    cb_ntfy.setListener(new NotifyEventListener() {
        @Override
        public void positiveResponse(Context c, Object[] o) {
            int p = (Integer) o[0];
            boolean p_chk = (Boolean) o[1];
            String turl = (String) mLocalMountPointSpinner.getSelectedItem();
            if (mDialogSingleSelect) {
                if (mTreeFilelistAdapter.getDataItem(p).isChecked() && !p_chk) {
                    if (p != -1) {
                        if (mTreeFilelistAdapter.getDataItem(p).isChecked()) {
                            if (mTreeFilelistAdapter.getDataItem(p).isDir()) {
                                dir_name.setText(turl + mTreeFilelistAdapter.getDataItem(p).getPath()
                                        + mTreeFilelistAdapter.getDataItem(p).getName() + "/");
                                //                           file_name.setText("");
                            } else {
                                dir_name.setText(turl + mTreeFilelistAdapter.getDataItem(p).getPath());
                                file_name.setText(mTreeFilelistAdapter.getDataItem(p).getName());
                            }
                        }
                    }
                }
                if (mDialogFileOnly) {
                    if (file_name.getText().length() > 0) {
                        btnOk.setEnabled(true);
                        putDlgMsg(dlg_msg, "");
                    } else {
                        btnOk.setEnabled(false);
                        putDlgMsg(dlg_msg,
                                context.getString(R.string.msgs_file_select_edit_dlg_filename_not_specified));
                    }
                } else {
                    if (mTreeFilelistAdapter.isDataItemIsSelected() || file_name.getText().length() > 0) {
                        btnOk.setEnabled(true);
                        putDlgMsg(dlg_msg, "");
                    } else {
                        putDlgMsg(dlg_msg,
                                context.getString(R.string.msgs_file_select_edit_dlg_directory_not_selected));
                        btnOk.setEnabled(false);
                    }
                }
            } else {
                if (mTreeFilelistAdapter.getDataItem(p).isDir()) {
                    dir_name.setText(turl + mTreeFilelistAdapter.getDataItem(p).getPath()
                            + mTreeFilelistAdapter.getDataItem(p).getName() + "/");
                    //                  file_name.setText("");
                } else {
                    dir_name.setText(turl + mTreeFilelistAdapter.getDataItem(p).getPath());
                    file_name.setText(mTreeFilelistAdapter.getDataItem(p).getName());
                }
                putDlgMsg(dlg_msg, "");
                btnOk.setEnabled(true);
            }
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
            boolean checked = false;
            //         int p=(Integer) o[0];
            boolean p_chk = (Boolean) o[1];
            if (mDialogSingleSelect) {
                if (p_chk) {
                    for (int i = 0; i < mTreeFilelistAdapter.getDataItemCount(); i++) {
                        if (mTreeFilelistAdapter.getDataItem(i).isChecked()) {
                            checked = true;
                            break;
                        }
                    }
                    if (checked)
                        btnOk.setEnabled(true);
                    else
                        btnOk.setEnabled(false);
                }
            } else {
                //               Log.v("","sel="+p_chk);
                btnOk.setEnabled(false);
                for (int i = 0; i < mTreeFilelistAdapter.getDataItemCount(); i++) {
                    if (mTreeFilelistAdapter.getDataItem(i).isChecked()) {
                        btnOk.setEnabled(true);
                        break;
                    }
                }
            }
        }
    });
    mTreeFilelistAdapter.setCbCheckListener(cb_ntfy);

    if (mDialogLocalUrl.equals(file_name.getText().toString()))
        btnOk.setEnabled(false);
    if (mDialogFileOnly && mDialogFileName.equals("")) {
        btnOk.setEnabled(false);
        putDlgMsg(dlg_msg, context.getString(R.string.msgs_file_select_edit_dlg_filename_not_specified));
    }
    file_name.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            if (mDialogSingleSelect) {
                if (s.length() != 0) {
                    btnOk.setEnabled(true);
                    putDlgMsg(dlg_msg, "");
                } else {
                    btnOk.setEnabled(false);
                    putDlgMsg(dlg_msg,
                            context.getString(R.string.msgs_file_select_edit_dlg_filename_not_specified));
                }
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });

    NotifyEvent ntfy_expand_close = new NotifyEvent(context);
    ntfy_expand_close.setListener(new NotifyEventListener() {
        @Override
        public void positiveResponse(Context c, Object[] o) {
            int idx = (Integer) o[0];
            final int pos = mTreeFilelistAdapter.getItem(idx);
            final TreeFilelistItem tfi = mTreeFilelistAdapter.getDataItem(pos);
            if (tfi.getName().startsWith("---"))
                return;
            String turl = (String) mLocalMountPointSpinner.getSelectedItem();
            if (tfi.isDir())
                processLocalDirTree(mDialogFileOnly, turl, pos, tfi, mTreeFilelistAdapter);
            else {
                mTreeFilelistAdapter.setDataItemIsSelected(pos);
                dir_name.setText((turl + mTreeFilelistAdapter.getDataItem(pos).getPath()));
                file_name.setText(mTreeFilelistAdapter.getDataItem(pos).getName());
                if (mTreeFilelistAdapter.getDataItem(pos).isDir() && mDialogFileOnly)
                    btnOk.setEnabled(false);
                else
                    btnOk.setEnabled(true);
            }
        }

        @Override
        public void negativeResponse(Context c, Object[] o) {
        }
    });
    mTreeFilelistAdapter.setExpandCloseListener(ntfy_expand_close);
    mTreeFileListView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> items, View view, int idx, long id) {
            final int pos = mTreeFilelistAdapter.getItem(idx);
            final TreeFilelistItem tfi = mTreeFilelistAdapter.getDataItem(pos);
            if (tfi.getName().startsWith("---"))
                return;
            String turl = (String) mLocalMountPointSpinner.getSelectedItem();
            if (tfi.isDir())
                processLocalDirTree(mDialogFileOnly, turl, pos, tfi, mTreeFilelistAdapter);
            else {
                mTreeFilelistAdapter.setDataItemIsSelected(pos);
                dir_name.setText((turl + mTreeFilelistAdapter.getDataItem(pos).getPath()));
                file_name.setText(mTreeFilelistAdapter.getDataItem(pos).getName());
                if (mTreeFilelistAdapter.getDataItem(pos).isDir() && mDialogFileOnly)
                    btnOk.setEnabled(false);
                else
                    btnOk.setEnabled(true);
            }
        }
    });

    mTreeFileListView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {
            return true;
        }
    });

    btnHome.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dir_name.setText(mLocalMountPointSpinner.getSelectedItem().toString() + "/");
        }
    });

    //Create button
    btnCreate.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            NotifyEvent ntfy = new NotifyEvent(context);
            // set file list thread response listener 
            ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context c, Object[] o) {
                    //                  btnRefresh.performClick();                  
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                }

            });
            fileSelectEditDialogCreateBtn(activity, context,
                    dir_name.getText().substring(0, dir_name.getText().length() - 1), "",
                    mLocalMountPointSpinner.getSelectedItem().toString(), mTreeFilelistAdapter, ntfy,
                    mTreeFileListView);

        }
    });
    //Refresh button
    btnRefresh.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String mp = mLocalMountPointSpinner.getSelectedItem().toString();
            ArrayList<TreeFilelistItem> tfl = createLocalFilelist(mDialogFileOnly, mp, "");//mDialogLocalUrl,"");
            if (tfl.size() < 1)
                tfl.add(new TreeFilelistItem(context.getString(R.string.msgs_file_select_edit_dir_empty)));
            mTreeFilelistAdapter.setDataList(tfl);
        }
    });
    //OK button
    //      btnOk.setEnabled(false);
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (mDialogSingleSelect) {
                String[] sl_array = new String[] { dir_name.getText() + file_name.getText().toString() };
                if (mNotifyEvent != null)
                    mNotifyEvent.notifyToListener(true, sl_array);
            } else {
                ArrayList<String> sl = new ArrayList<String>();
                ArrayList<TreeFilelistItem> tfl = mTreeFilelistAdapter.getDataList();
                for (TreeFilelistItem li : tfl) {
                    if (li.isChecked()) {
                        if (li.isDir())
                            sl.add(li.getPath() + li.getName());
                        else
                            sl.add(li.getPath() + li.getName());
                    }
                }
                String[] sl_array = new String[sl.size()];
                String mp = mLocalMountPointSpinner.getSelectedItem().toString();
                for (int i = 0; i < sl.size(); i++) {
                    if (mDialogSelectedFilePathWithMountPoint)
                        sl_array[i] = mp + sl.get(i);
                    else
                        sl_array[i] = sl.get(i);
                    //                  Log.v("","sel="+sl_array[i]);
                }
                if (mNotifyEvent != null)
                    mNotifyEvent.notifyToListener(true, sl_array);
            }
            //            mDialog.dismiss();
            mFragment.dismiss();
        }
    });
    // CANCEL?
    btnCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //            mDialog.dismiss();
            mFragment.dismiss();
            if (mNotifyEvent != null)
                mNotifyEvent.notifyToListener(false, null);
        }
    });

    Handler hndl = new Handler();
    hndl.postDelayed(new Runnable() {
        @Override
        public void run() {
            mLocalMountPointSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                @Override
                public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                    //                    Log.v("","MP selected="+position);
                    Spinner spinner = (Spinner) parent;
                    String turl = (String) spinner.getSelectedItem();
                    ArrayList<TreeFilelistItem> tfl = createLocalFilelist(mDialogFileOnly, turl, "");
                    if (tfl.size() < 1)
                        tfl.add(new TreeFilelistItem(
                                context.getString(R.string.msgs_file_select_edit_dir_empty)));
                    mTreeFilelistAdapter.setDataList(tfl);
                    mTreeFilelistAdapter.notifyDataSetChanged();
                    if (turl.startsWith(mSafFileMgr.getExternalSdcardPath())) {
                        if (mSafFileMgr.getSdcardSafFile() == null)
                            btnCreate.setEnabled(false);
                        else
                            btnCreate.setEnabled(true);
                    } else
                        btnCreate.setEnabled(true);
                    dir_name.setText(turl + "/");
                    Handler hndl_sel = new Handler();
                    hndl_sel.post(new Runnable() {
                        @Override
                        public void run() {
                            mTreeFileListView.setSelection(0);
                        }
                    });
                }

                @Override
                public void onNothingSelected(AdapterView<?> arg0) {
                }
            });
        }
    }, 100);
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    switch (id) {
    case DIALOG_CREATE_SHORTCUT:
        break;/*ww w  . ja v  a  2  s.  c o  m*/
    case DIALOG_RENAME_FOLDER:
        if (mFolderInfo != null) {
            EditText input = (EditText) dialog.findViewById(R.id.folder_name);
            final CharSequence text = mFolderInfo.title;
            input.setText(text);
            input.setSelection(0, text.length());
        }
        break;
    }
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java

private void restoreViewContents(final SavedViewContents sv) {
    final EditText dlg_prof_name_et = (EditText) mDialog.findViewById(R.id.edit_profile_action_profile_et_name);
    final CheckBox cb_active = (CheckBox) mDialog.findViewById(R.id.edit_profile_action_enabled);
    final CheckBox cb_enable_env_parms = (CheckBox) mDialog
            .findViewById(R.id.edit_profile_action_enable_env_parms);

    final TextView tv_sound_filename = (TextView) mDialog
            .findViewById(R.id.edit_profile_action_exec_sound_file_name);
    final CheckBox cb_music_vol = (CheckBox) mDialog
            .findViewById(R.id.edit_profile_action_profile_sound_use_volume);
    final SeekBar sb_music_vol = (SeekBar) mDialog.findViewById(R.id.edit_profile_action_profile_sound_volume);
    final CheckBox cb_ringtone_vol = (CheckBox) mDialog
            .findViewById(R.id.edit_profile_action_profile_ringtone_use_volume);
    final SeekBar sb_ringtone_vol = (SeekBar) mDialog
            .findViewById(R.id.edit_profile_action_profile_ringtone_volume);
    final Spinner spinnerActionType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_action_type);
    final Spinner spinnerActivityName = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_activity_name);
    final Spinner spinnerActivityDataType = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_activity_data_type);
    final Spinner spinnerRingtoneType = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_ringtone_type);
    final Spinner spinnerRingtoneName = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_exec_ringtone_name);
    final Spinner spinnerCompareType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_compare_type);
    final EditText et_comp_value1 = (EditText) mDialog.findViewById(R.id.edit_profile_action_compare_value1);
    final EditText et_comp_value2 = (EditText) mDialog.findViewById(R.id.edit_profile_action_compare_value2);
    final ListView lv_comp_data = (ListView) mDialog
            .findViewById(R.id.edit_profile_action_compare_value_listview);
    final Spinner spinnerCompareResult = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_compare_result);
    final Spinner spinnerCompareTarget = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_compare_target);
    final Spinner spinnerMessageType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_message_type);
    final EditText et_msg_text = (EditText) mDialog.findViewById(R.id.edit_profile_action_message_message);
    final CheckBox cb_vib_used = (CheckBox) mDialog.findViewById(R.id.edit_profile_action_message_vibration);
    final CheckBox cb_led_used = (CheckBox) mDialog.findViewById(R.id.edit_profile_action_message_led);
    final RadioButton rb_msg_blue = (RadioButton) mDialog
            .findViewById(R.id.edit_profile_action_message_led_blue);
    final RadioButton rb_msg_red = (RadioButton) mDialog.findViewById(R.id.edit_profile_action_message_led_red);
    final RadioButton rb_msg_green = (RadioButton) mDialog
            .findViewById(R.id.edit_profile_action_message_led_green);
    final Spinner spinnerTimeType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_time_type);
    final Spinner spinnerTimeTarget = (Spinner) mDialog.findViewById(R.id.edit_profile_action_time_target);
    final Spinner spinnerTaskType = (Spinner) mDialog.findViewById(R.id.edit_profile_action_task_type);
    final Spinner spinnerTaskTarget = (Spinner) mDialog.findViewById(R.id.edit_profile_action_task_target);
    final Spinner spinnerWaitTarget = (Spinner) mDialog.findViewById(R.id.edit_profile_action_wait_target);
    final Spinner spinnerWaitTimeoutType = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_wait_timeout);
    final Spinner spinnerWaitTimeoutValue = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_wait_timeout_value);
    final Spinner spinnerWaitTimeoutUnits = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_wait_timeout_units);
    final EditText et_bsh_script = (EditText) mDialog
            .findViewById(R.id.edit_profile_action_dlg_bsh_script_text);
    final Spinner spinnerBshMethod = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_dlg_bsh_add_method);
    final Spinner spinnerCatMethod = (Spinner) mDialog
            .findViewById(R.id.edit_profile_action_dlg_bsh_cat_method);

    final EditText uri_data = (EditText) mDialog.findViewById(R.id.edit_profile_action_exec_activity_uri_data);
    final ListView lv_aed = (ListView) mDialog
            .findViewById(R.id.edit_profile_action_exec_activity_extra_data_listview);

    dlg_prof_name_et.setText(sv.dlg_prof_name_et);
    dlg_prof_name_et.setSelection(sv.dlg_prof_name_et_spos, sv.dlg_prof_name_et_epos);
    cb_active.setChecked(sv.cb_active);/*from   w w  w .j  a  va 2 s. co m*/
    tv_sound_filename.setText(sv.tv_sound_filename);
    cb_music_vol.setChecked(sv.cb_music_vol);
    sb_music_vol.setProgress(sv.sb_music_vol);
    cb_ringtone_vol.setChecked(sv.cb_ringtone_vol);
    sb_ringtone_vol.setProgress(sv.sb_ringtone_vol);
    et_comp_value1.setText(sv.et_comp_value1);
    et_comp_value2.setText(sv.et_comp_value2);
    lv_comp_data.setSelectionFromTop(sv.lv_comp_data[0], sv.lv_comp_data[1]);
    et_msg_text.setText(sv.et_msg_text);
    cb_vib_used.setChecked(sv.cb_vib_used);
    cb_led_used.setChecked(sv.cb_led_used);
    if (sv.rb_msg_blue)
        rb_msg_blue.setChecked(sv.rb_msg_blue);
    if (sv.rb_msg_red)
        rb_msg_red.setChecked(sv.rb_msg_red);
    if (sv.rb_msg_green)
        rb_msg_green.setChecked(sv.rb_msg_green);
    et_bsh_script.setText(sv.et_bsh_script);
    uri_data.setText(sv.uri_data);
    lv_aed.setSelectionFromTop(sv.lv_aed[0], sv.lv_aed[1]);
    cb_enable_env_parms.setChecked(sv.cb_enable_env_parms);

    for (int i = 0; i < mGlblParms.activityExtraDataEditListAdapter.getCount(); i++)
        mGlblParms.activityExtraDataEditListAdapter.remove(0);
    for (int i = 0; i < sv.aed_adapter_list.size(); i++)
        mGlblParms.activityExtraDataEditListAdapter.add(sv.aed_adapter_list.get(i));
    mGlblParms.activityExtraDataEditListAdapter.notifyDataSetChanged();

    for (int i = 0; i < mGlblParms.actionCompareDataAdapter.getCount(); i++)
        mGlblParms.actionCompareDataAdapter.remove(0);
    for (int i = 0; i < sv.data_array_adapter_list.size(); i++)
        mGlblParms.actionCompareDataAdapter.add(sv.data_array_adapter_list.get(i));
    mGlblParms.actionCompareDataAdapter.notifyDataSetChanged();

    spinnerActionType.setSelection(sv.spinnerActionType);
    spinnerActivityName.setSelection(sv.spinnerActivityName);
    spinnerActivityDataType.setSelection(sv.spinnerActivityDataType);
    spinnerRingtoneType.setSelection(sv.spinnerRingtoneType);
    spinnerRingtoneName.setSelection(sv.spinnerRingtoneName);
    spinnerCompareType.setSelection(sv.spinnerCompareType);
    spinnerCompareResult.setSelection(sv.spinnerCompareResult);
    spinnerCompareTarget.setSelection(sv.spinnerCompareTarget);
    spinnerMessageType.setSelection(sv.spinnerMessageType);
    spinnerTimeType.setSelection(sv.spinnerTimeType);
    spinnerTimeTarget.setSelection(sv.spinnerTimeTarget);
    spinnerTaskType.setSelection(sv.spinnerTaskType);
    spinnerTaskTarget.setSelection(sv.spinnerTaskTarget);
    spinnerWaitTarget.setSelection(sv.spinnerWaitTarget);
    spinnerWaitTimeoutType.setSelection(sv.spinnerWaitTimeoutType);
    spinnerWaitTimeoutValue.setSelection(sv.spinnerWaitTimeoutValue);
    spinnerWaitTimeoutUnits.setSelection(sv.spinnerWaitTimeoutUnits);
    spinnerBshMethod.setSelection(sv.spinnerBshMethod);
    spinnerCatMethod.setSelection(sv.spinnerCatMethod);

    //       Handler hndl1=new Handler();
    //       hndl1.postDelayed(new Runnable(){
    //         @Override
    //         public void run() {
    //
    //            Handler hndl2=new Handler();
    //             hndl2.postDelayed(new Runnable(){
    //               @Override
    //               public void run() {
    //               }
    //             },50);
    //         }
    //       },50);
}