Example usage for android.app Dialog requestWindowFeature

List of usage examples for android.app Dialog requestWindowFeature

Introduction

In this page you can find the example usage for android.app Dialog requestWindowFeature.

Prototype

public final boolean requestWindowFeature(int featureId) 

Source Link

Document

Enable extended window features.

Usage

From source file:group.pals.android.lib.ui.filechooser.utils.ui.history.HistoryFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(_ClassName, "onCreateDialog()");
    Dialog dialog = new Dialog(getActivity(), R.style.Afc_Theme_Dialog_Dark) {

        @Override/* ww  w.j  a  v  a2s  .  c om*/
        public boolean onCreateOptionsMenu(Menu menu) {
            getActivity().getMenuInflater().inflate(R.menu.afc_viewgroup_history, menu);
            return super.onCreateOptionsMenu(menu);
        }// onCreateOptionsMenu()

        @Override
        public boolean onPrepareOptionsMenu(Menu menu) {
            menu.findItem(R.id.afc_menuitem_clear)
                    .setEnabled(mHistoryCursorAdapter != null && mHistoryCursorAdapter.getGroupCount() > 0);
            return true;
        }// onPrepareOptionsMenu()

        @Override
        public boolean onMenuItemSelected(int featureId, MenuItem item) {
            if (BuildConfig.DEBUG)
                Log.d(_ClassName, "onMenuItemSelected() in Dialog");

            Ui.showSoftKeyboard(mSearchView, false);

            if (item.getItemId() == R.id.afc_menuitem_clear)
                doConfirmClearHistory();

            return true;
        }// onMenuItemSelected()
    };

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setContentView(initContentView(dialog.getLayoutInflater(), null));
    dialog.setOnKeyListener(mDialogOnKeyListener);

    Ui.adjustDialogSizeForLargeScreen(dialog);

    return dialog;
}

From source file:androidVNC.VncCanvasActivity.java

private void selectColorModel() {
    // Stop repainting the desktop
    // because the display is composited!
    vncCanvas.disableRepaints();/*w  ww  .  j av  a2s .  c o  m*/

    String[] choices = new String[COLORMODEL.values().length];
    int currentSelection = -1;
    for (int i = 0; i < choices.length; i++) {
        COLORMODEL cm = COLORMODEL.values()[i];
        choices[i] = cm.toString();
        if (vncCanvas.isColorModel(cm))
            currentSelection = i;
    }

    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    ListView list = new ListView(this);
    list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, choices));
    list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    list.setItemChecked(currentSelection, true);
    list.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            dialog.dismiss();
            COLORMODEL cm = COLORMODEL.values()[arg2];
            vncCanvas.setColorModel(cm);
            connection.setColorModel(cm.nameString());
            connection.save(database.getWritableDatabase());
            //Toast.makeText(VncCanvasActivity.this,"Updating Color Model to " + cm.toString(), Toast.LENGTH_SHORT).show();
        }
    });
    dialog.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface arg0) {
            Log.i(TAG, "Color Model Selector dismissed");
            // Restore desktop repaints
            vncCanvas.enableRepaints();
        }
    });
    dialog.setContentView(list);
    dialog.show();
}

From source file:co.taqat.call.LinphoneActivity.java

public Dialog displayWrongPasswordDialog(final String username, final String realm, final String domain) {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorC));
    d.setAlpha(200);//  w  w  w  .  ja v  a 2s  . co  m
    dialog.setContentView(R.layout.input_dialog);
    dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT);
    dialog.getWindow().setBackgroundDrawable(d);

    TextView customText = (TextView) dialog.findViewById(R.id.customText);
    customText.setText(getString(R.string.error_bad_credentials));

    Button retry = (Button) dialog.findViewById(R.id.retry);
    Button cancel = (Button) dialog.findViewById(R.id.cancel);

    retry.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            String newPassword = ((EditText) dialog.findViewById(R.id.password)).getText().toString();
            LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance().createAuthInfo(username, null,
                    newPassword, null, realm, domain);
            LinphoneManager.getLc().addAuthInfo(authInfo);
            LinphoneManager.getLc().refreshRegisters();
            dialog.dismiss();
        }
    });

    cancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    return dialog;
}

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

final static private void editDataArrayListItem(final GlobalParameters mGlblParms, final String edit_data,
        final int pos) {
    final Dialog dialog = new Dialog(mGlblParms.context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //      dialog.getWindow().setSoftInputMode(
    //                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    dialog.setContentView(R.layout.data_array_item_edit_dlg);
    //      final TextView dlg_msg = (TextView) dialog.findViewById(R.id.data_array_item_edit_dlg_msg);
    final TextView dlg_title = (TextView) dialog.findViewById(R.id.data_array_item_edit_dlg_title);
    dlg_title.setText("Edit data");
    final EditText dlg_value = (EditText) dialog.findViewById(R.id.data_array_item_edit_dlg_value);
    final Button dlg_apply = (Button) dialog.findViewById(R.id.data_array_item_edit_dlg_apply);
    final Button dlg_cancel = (Button) dialog.findViewById(R.id.data_array_item_edit_dlg_cancel);

    //      CommonDialog.setDlgBoxSizeCompact(dialog);

    dlg_value.setText(edit_data);//from  w  w  w  .j  a v  a 2  s  .  co  m

    // CANCEL?
    dlg_cancel.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            mGlblParms.actionCompareDataAdapter.getItem(pos).while_edit = false;
            mGlblParms.actionCompareDataAdapter.notifyDataSetChanged();
            dialog.dismiss();
        }
    });
    // Apply?
    dlg_apply.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            mGlblParms.actionCompareDataAdapter.getItem(pos).while_edit = false;
            mGlblParms.actionCompareDataAdapter.getItem(pos).data_value = dlg_value.getText().toString();
            mGlblParms.actionCompareDataAdapter.notifyDataSetChanged();
            dialog.dismiss();
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            dlg_cancel.performClick();
        }
    });
    //      dialog.setCancelable(false);
    dialog.show();
}

From source file:org.thoughtland.xlocation.ActivityApp.java

private void optionLegend() {
    // Show help//from  w  w  w .  j a  va 2  s  .c o  m
    Dialog dialog = new Dialog(ActivityApp.this);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setTitle(R.string.menu_legend);
    dialog.setContentView(R.layout.legend);
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher));

    ((ImageView) dialog.findViewById(R.id.imgHelpHalf)).setImageBitmap(getHalfCheckBox());
    ((ImageView) dialog.findViewById(R.id.imgHelpOnDemand)).setImageBitmap(getOnDemandCheckBox());

    for (View child : Util.getViewsByTag((ViewGroup) dialog.findViewById(android.R.id.content), "main"))
        child.setVisibility(View.GONE);

    ((LinearLayout) dialog.findViewById(R.id.llUnsafe))
            .setVisibility(PrivacyManager.cVersion3 ? View.VISIBLE : View.GONE);

    dialog.setCancelable(true);
    dialog.show();
}

From source file:com.haibison.android.anhuu.utils.ui.history.HistoryFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(CLASSNAME, "onCreateDialog()");
    Dialog dialog = new Dialog(getActivity(),
            UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_theme_dialog)) {

        @Override//from  w ww .j a v a2 s  . c o  m
        public boolean onCreateOptionsMenu(Menu menu) {
            getActivity().getMenuInflater().inflate(R.menu.anhuu_f5be488d_viewgroup_history, menu);
            return super.onCreateOptionsMenu(menu);
        }// onCreateOptionsMenu()

        @Override
        public boolean onPrepareOptionsMenu(Menu menu) {
            menu.findItem(R.id.anhuu_f5be488d_menuitem_clear)
                    .setEnabled(mHistoryCursorAdapter != null && mHistoryCursorAdapter.getGroupCount() > 0);
            return true;
        }// onPrepareOptionsMenu()

        @Override
        public boolean onMenuItemSelected(int featureId, MenuItem item) {
            if (BuildConfig.DEBUG)
                Log.d(CLASSNAME, "onMenuItemSelected() in Dialog");

            UI.showSoftKeyboard(mSearchView, false);

            if (item.getItemId() == R.id.anhuu_f5be488d_menuitem_clear)
                doConfirmClearHistory();

            return true;
        }// onMenuItemSelected()
    };

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(true);
    dialog.setContentView(initContentView(dialog.getLayoutInflater(), null));
    dialog.setOnKeyListener(mDialogOnKeyListener);

    UI.adjustDialogSizeForLargeScreens(dialog);

    return dialog;
}

From source file:es.javocsoft.android.lib.toolbox.ToolBox.java

/**
 * "Coach mark" (help overlay image)//from   w  ww.  ja  v a 2s . com
 * 
 * @param context
 * @param coachMarkLayoutId   Is "Help overlay" layout id in UX talk :-) 
 *             [coach_mark.xml is your coach mark layout]
 * @param coachMarkMasterViewId   is the id of the top most view in coach_mark.xml
 */
public static void dialog_onCoachMark(Context context, int coachMarkLayoutId, int coachMarkMasterViewId,
        int bgColor) {

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(bgColor));
    dialog.setContentView(coachMarkLayoutId);
    dialog.setCanceledOnTouchOutside(true);

    //for dismissing anywhere you touch
    View masterView = dialog.findViewById(coachMarkMasterViewId);
    masterView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

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

final static private void editActivityExtraDataItem(final GlobalParameters mGlblParms, final int sel_pos) {
    // ??//from  w w w  . j ava 2  s  .  c  o m
    final Dialog dialog = new Dialog(mGlblParms.context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //      dialog.getWindow().setSoftInputMode(
    //                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    dialog.setContentView(R.layout.edit_activity_extra_data_item_dlg);
    final TextView dlg_msg = (TextView) dialog.findViewById(R.id.edit_activity_extra_data_item_msg);
    //      final TextView dlg_title = (TextView) dialog.findViewById(R.id.edit_activity_extra_data_item_title);

    //      CommonDialog.setDlgBoxSizeLimit(dialog,true);
    final Button btn_cancel = (Button) dialog.findViewById(R.id.edit_activity_extra_data_item_cancel_btn);
    final Button btn_ok = (Button) dialog.findViewById(R.id.edit_activity_extra_data_item_ok_btn);

    final EditText et_key = (EditText) dialog.findViewById(R.id.edit_activity_extra_data_item_key);
    final EditText et_string = (EditText) dialog.findViewById(R.id.edit_activity_extra_data_item_data_string);
    final EditText et_int = (EditText) dialog.findViewById(R.id.edit_activity_extra_data_item_data_int);
    final CheckBox cb_array = (CheckBox) dialog.findViewById(R.id.edit_activity_extra_data_item_array);
    final Button btn_add_array = (Button) dialog.findViewById(R.id.edit_activity_extra_data_item_add_array);
    final ListView lv_array = (ListView) dialog.findViewById(R.id.edit_activity_extra_data_item_array_listview);
    final TextView lv_spacer = (TextView) dialog.findViewById(R.id.edit_activity_extra_data_item_array_spacer);

    final Spinner spinnerExtraDataType = (Spinner) dialog
            .findViewById(R.id.edit_activity_extra_data_item_data_type);
    final CustomSpinnerAdapter adapterExtraDataType = new CustomSpinnerAdapter(mGlblParms.context,
            R.layout.custom_simple_spinner_item);
    adapterExtraDataType.setTextColor(Color.BLACK);
    setSpinnerExtraDataType(mGlblParms, dialog, spinnerExtraDataType, adapterExtraDataType,
            PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING);

    final Spinner spinnerExtraDataBoolean = (Spinner) dialog
            .findViewById(R.id.edit_activity_extra_data_item_data_boolean);
    final CustomSpinnerAdapter adapterExtraDataBoolean = new CustomSpinnerAdapter(mGlblParms.context,
            R.layout.custom_simple_spinner_item);
    adapterExtraDataBoolean.setTextColor(Color.BLACK);
    setSpinnerExtraDataBoolean(mGlblParms, dialog, spinnerExtraDataBoolean, adapterExtraDataBoolean, "false");

    final Button update_apply = (Button) dialog
            .findViewById(R.id.edit_activity_extra_data_item_data_update_apply);
    final Button update_cancel = (Button) dialog
            .findViewById(R.id.edit_activity_extra_data_item_data_update_cancel);
    update_apply.setVisibility(Button.GONE);
    update_cancel.setVisibility(Button.GONE);
    spinnerExtraDataBoolean.setVisibility(Spinner.GONE);
    et_string.setVisibility(EditText.GONE);
    et_int.setVisibility(EditText.GONE);
    btn_add_array.setVisibility(Button.GONE);
    lv_array.setVisibility(ListView.GONE);
    lv_spacer.setVisibility(TextView.VISIBLE);

    final ArrayList<DataArrayEditListItem> aed_array_list = new ArrayList<DataArrayEditListItem>();
    final AdapterDataArrayEditList aed_array_adapter = new AdapterDataArrayEditList(mGlblParms.context,
            R.layout.data_array_edit_list_item, aed_array_list);
    lv_array.setAdapter(aed_array_adapter);
    setActivityExtraDataEditItemViewVisibility(mGlblParms, dialog, aed_array_adapter, spinnerExtraDataType);

    cb_array.setChecked(false);
    if (sel_pos != -1) {
        et_key.setEnabled(false);
        et_key.setTextColor(Color.WHITE);
        et_key.selectAll();
        et_key.setText(mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).key_value);
        if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type
                .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) {
            et_string.setText(mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_value);
            spinnerExtraDataType.setSelection(0);
        } else if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type
                .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) {
            et_int.setText(mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_value);
            spinnerExtraDataType.setSelection(1);
        } else if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type
                .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) {
            spinnerExtraDataType.setSelection(2);
            if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_value.equals("false"))
                spinnerExtraDataBoolean.setSelection(0);
            else
                spinnerExtraDataBoolean.setSelection(1);
        }
        mGlblParms.currentSelectedExtraDataType = spinnerExtraDataType.getSelectedItem().toString();
        if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_value_array
                .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_ARRAY_YES)) {
            cb_array.setChecked(true);
            et_string.setText("");
            et_int.setText("");
            createActivityExtraDataArrayList(aed_array_adapter,
                    mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos));
            aed_array_adapter.notifyDataSetChanged();
            update_apply.setVisibility(Button.GONE);
            update_cancel.setVisibility(Button.GONE);
            spinnerExtraDataBoolean.setVisibility(Spinner.GONE);
            et_string.setVisibility(EditText.GONE);
            et_int.setVisibility(EditText.GONE);
            btn_add_array.setVisibility(Button.VISIBLE);
            lv_array.setVisibility(ListView.VISIBLE);
            lv_spacer.setVisibility(TextView.GONE);
        } else {
            cb_array.setChecked(false);
            update_apply.setVisibility(Button.GONE);
            update_cancel.setVisibility(Button.GONE);
            spinnerExtraDataBoolean.setVisibility(Spinner.GONE);
            et_string.setVisibility(EditText.GONE);
            et_int.setVisibility(EditText.GONE);
            btn_add_array.setVisibility(Button.GONE);
            lv_array.setVisibility(ListView.GONE);
            lv_spacer.setVisibility(TextView.VISIBLE);
            if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) {
                et_string.setVisibility(EditText.VISIBLE);
            } else if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) {
                et_int.setVisibility(EditText.VISIBLE);
            } else if (mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos).data_type
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) {
                spinnerExtraDataBoolean.setVisibility(Spinner.VISIBLE);
            }
        }
    }

    btn_add_array.setOnClickListener(new OnClickListener() {
        @Override
        final public void onClick(View arg0) {
            String n_data = "";
            if (spinnerExtraDataType.getSelectedItem()
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) {
                n_data = "";
            } else if (spinnerExtraDataType.getSelectedItem()
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) {
                n_data = "0";
            } else if (spinnerExtraDataType.getSelectedItem()
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) {
                n_data = "false";
            }
            DataArrayEditListItem aeda_item = new DataArrayEditListItem();
            aeda_item.data_value = n_data;
            aed_array_adapter.add(aeda_item);
            aed_array_adapter.notifyDataSetChanged();
        }
    });

    NotifyEvent ntfy = new NotifyEvent(mGlblParms.context);
    ntfy.setListener(new NotifyEventListener() {
        @Override
        final public void positiveResponse(Context c, Object[] o) {
            spinnerExtraDataType.setEnabled(false);
            String c_data = (String) o[0];
            if (spinnerExtraDataType.getSelectedItem()
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) {
                et_string.setText(c_data);
                spinnerExtraDataBoolean.setVisibility(Spinner.GONE);
                et_string.setVisibility(EditText.VISIBLE);
                et_int.setVisibility(EditText.GONE);
                et_string.requestFocus();
            } else if (spinnerExtraDataType.getSelectedItem()
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) {
                et_int.setText(c_data);
                spinnerExtraDataBoolean.setVisibility(Spinner.GONE);
                et_string.setVisibility(EditText.GONE);
                et_int.setVisibility(EditText.VISIBLE);
                et_int.requestFocus();
            } else if (spinnerExtraDataType.getSelectedItem()
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) {
                if (c_data.equals("false"))
                    spinnerExtraDataBoolean.setSelection(0);
                else
                    spinnerExtraDataBoolean.setSelection(1);
                spinnerExtraDataBoolean.setVisibility(Spinner.VISIBLE);
                et_string.setVisibility(EditText.GONE);
                et_int.setVisibility(EditText.GONE);
            }
            update_apply.setVisibility(Button.VISIBLE);
            update_cancel.setVisibility(Button.VISIBLE);
            btn_ok.setEnabled(false);
            btn_cancel.setEnabled(false);
            cb_array.setEnabled(false);
            btn_add_array.setEnabled(false);

        }

        @Override
        final public void negativeResponse(Context c, Object[] o) {
        }
    });
    aed_array_adapter.setEditBtnNotifyListener(ntfy);
    update_apply.setVisibility(Button.GONE);
    update_cancel.setVisibility(Button.GONE);
    update_apply.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            boolean no_err = auditActivityExtraData(mGlblParms, dialog, spinnerExtraDataType,
                    spinnerExtraDataBoolean);
            if (!no_err)
                return;
            int pos = -1;
            for (int i = 0; i < aed_array_list.size(); i++) {
                if (aed_array_list.get(i).while_edit) {
                    pos = i;
                    break;
                }
            }
            if (spinnerExtraDataType.getSelectedItem()
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) {
                aed_array_list.get(pos).data_value = et_string.getText().toString();
                aed_array_list.get(pos).while_edit = false;
            } else if (spinnerExtraDataType.getSelectedItem()
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) {
                aed_array_list.get(pos).data_value = et_int.getText().toString();
                aed_array_list.get(pos).while_edit = false;
            } else if (spinnerExtraDataType.getSelectedItem()
                    .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) {
                String n_boolean = "true";
                if (spinnerExtraDataBoolean.getSelectedItem().toString().equals("false"))
                    n_boolean = "false";
                aed_array_list.get(pos).data_value = n_boolean;
                aed_array_list.get(pos).while_edit = false;
            }
            et_string.setText("");
            et_int.setText("");
            et_string.setVisibility(EditText.GONE);
            et_int.setVisibility(EditText.GONE);
            spinnerExtraDataBoolean.setVisibility(Spinner.GONE);
            aed_array_adapter.notifyDataSetChanged();
            update_apply.setVisibility(Button.GONE);
            update_cancel.setVisibility(Button.GONE);
            spinnerExtraDataType.setEnabled(true);
            btn_ok.setEnabled(true);
            btn_cancel.setEnabled(true);
            cb_array.setEnabled(true);
            btn_add_array.setEnabled(true);
        }
    });
    update_cancel.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            for (int i = 0; i < aed_array_list.size(); i++) {
                aed_array_list.get(i).while_edit = false;
            }
            et_string.setText("");
            et_int.setText("");
            et_string.setVisibility(EditText.GONE);
            et_int.setVisibility(EditText.GONE);
            spinnerExtraDataBoolean.setVisibility(Spinner.GONE);
            aed_array_adapter.notifyDataSetChanged();
            update_apply.setVisibility(Button.GONE);
            update_cancel.setVisibility(Button.GONE);
            spinnerExtraDataType.setEnabled(true);
            btn_ok.setEnabled(true);
            btn_cancel.setEnabled(true);
            cb_array.setEnabled(true);
            btn_add_array.setEnabled(true);
        }
    });

    // CANCEL?
    btn_cancel.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            dialog.dismiss();
        }
    });
    // OK?
    btn_ok.setOnClickListener(new View.OnClickListener() {
        final public void onClick(View v) {
            ActivityExtraDataItem aedi = null;
            if (sel_pos == -1) {//Add item
                if (et_key.getText().toString().equals("")) {
                    dlg_msg.setText(mGlblParms.context
                            .getString(R.string.msgs_edit_profile_action_activity_extra_data_key_name_missing));
                    return;
                }
                aedi = new ActivityExtraDataItem();
            } else {//Edit item
                aedi = mGlblParms.activityExtraDataEditListAdapter.getItem(sel_pos);
            }
            aedi.key_value = et_key.getText().toString();
            if (cb_array.isChecked()) {
                if (aed_array_list.size() == 0) {
                    dlg_msg.setText(mGlblParms.context.getString(
                            R.string.msgs_edit_profile_action_activity_extra_data_array_data_missing));
                    return;
                }
                aedi.data_value_array = PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_ARRAY_YES;
                aedi.data_type = spinnerExtraDataType.getSelectedItem().toString();
                aedi.data_value = "";
                //               Log.v("","array size="+aed_array_list.size());
                for (int i = 0; i < aed_array_list.size(); i++) {
                    if (aedi.data_type.equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) {
                        //                     aedi.data_value+="\u00a0"+aed_array_list.get(i).array_data_value+"\u0003";
                        aedi.data_value += aed_array_list.get(i).data_value + "\u0003";
                        //                     GeneralUtilities.hexString("String",aed_array_list.get(i).array_data_value.getBytes(),0,aed_array_list.get(i).array_data_value.getBytes().length);
                    } else {
                        aedi.data_value += aed_array_list.get(i).data_value + "\u0003";
                        //                     GeneralUtilities.hexString("int",aed_array_list.get(i).data_value.getBytes(),0,aed_array_list.get(i).data_value.getBytes().length);
                    }
                }
                //               GeneralUtilities.hexString("test",aedi.data_value.getBytes(),0,aedi.data_value.getBytes().length);
                //               Log.v("","dv="+aedi.data_value.replaceAll("\u0003", ";"));
            } else {
                boolean no_err = auditActivityExtraData(mGlblParms, dialog, spinnerExtraDataType,
                        spinnerExtraDataBoolean);
                if (!no_err)
                    return;
                else {
                    aedi.data_value_array = PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_ARRAY_NO;
                    aedi.data_type = spinnerExtraDataType.getSelectedItem().toString();
                    if (spinnerExtraDataType.getSelectedItem().toString()
                            .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) {
                        aedi.data_value = et_string.getText().toString();
                    } else if (spinnerExtraDataType.getSelectedItem().toString()
                            .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) {
                        aedi.data_value = et_int.getText().toString();
                    } else if (spinnerExtraDataType.getSelectedItem().toString()
                            .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) {
                        if (spinnerExtraDataBoolean.getSelectedItem().toString().equals("false"))
                            aedi.data_value = "false";
                        else
                            aedi.data_value = "true";
                    }
                }
            }
            if (sel_pos == -1)
                mGlblParms.activityExtraDataEditListAdapter.add(aedi);
            if (mGlblParms.activityExtraDataEditListAdapter.getItem(0).key_value.equals(""))
                mGlblParms.activityExtraDataEditListAdapter.remove(0);
            mGlblParms.activityExtraDataEditListAdapter.notifyDataSetChanged();

            dialog.dismiss();
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btn_cancel.performClick();
        }
    });
    //      dialog.setCancelable(false);
    dialog.show();
}

From source file:nu.yona.timepicker.time.TimePickerDialog.java

/**
 * Update Timepicker with new value//from  w w w .  j  a v a 2  s  . c o  m
 *//*
    private void updateTimePicker(Timepoint timePoint) {
    //Todo update according the selection time picker
            
    if (isSecondScreenVisible) {
            
    } else {
            
    }
            
    }*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}

From source file:com.example.yudiandrean.socioblood.FeedActivity.java

@SuppressLint("NewApi")
@Override/*from w w  w. j a  v a  2  s.c o  m*/
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    final Dialog d = new Dialog(context);
    setContentView(R.layout.feed_activity);
    postrequest = (TextView) findViewById(R.id.editText);

    WindowManager manager = (WindowManager) getSystemService(Activity.WINDOW_SERVICE);
    final int width, height;
    ActionBar.LayoutParams params;

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
        width = manager.getDefaultDisplay().getWidth();
        height = manager.getDefaultDisplay().getHeight();
    } else {
        Point point = new Point();
        manager.getDefaultDisplay().getSize(point);
        width = point.x;
        height = point.y;
    }

    session = new SessionManager(getApplicationContext());

    // Check if user is already logged in or not
    if (!session.isLoggedIn()) {
        // User is already logged in. Take him to main activity
        Intent intent = new Intent(FeedActivity.this, LoginActivity.class);
        startActivity(intent);
        finish();
    }

    listView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);
    feedItems = new ArrayList<FeedItem>();

    listAdapter = new FeedListAdapter(this, feedItems);
    listView.setAdapter(listAdapter);

    swipeRefreshLayout.setOnRefreshListener(this);

    // add button listener
    postrequest.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {

            try {
                d.requestWindowFeature(Window.FEATURE_NO_TITLE);
                d.setContentView(R.layout.post_request);
                WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
                lp.copyFrom(d.getWindow().getAttributes());
                lp.width = width;
                lp.height = height;
                d.getWindow().setAttributes(lp);
            } catch (AndroidRuntimeException e) {
            } catch (Exception e) {
            }

            final Spinner rhesusspinner = (Spinner) d.findViewById(R.id.rhesus_spinner);
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(FeedActivity.this,
                    android.R.layout.simple_spinner_dropdown_item) {

                @Override
                public View getView(int position, View convertView, ViewGroup parent) {

                    View v = super.getView(position, convertView, parent);
                    if (position == getCount()) {
                        ((TextView) v.findViewById(android.R.id.text1)).setText("");
                        ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
                    }

                    return v;
                }

                @Override
                public int getCount() {
                    return super.getCount() - 1; // you dont display last item. It is used as hint.
                }

            };

            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            adapter.add("+");
            adapter.add("-");
            adapter.add("Rhesus");

            rhesusspinner.setAdapter(adapter);
            rhesusspinner.setSelection(adapter.getCount()); //display hint

            final Spinner bloodspinner = (Spinner) d.findViewById(R.id.bloodtype_spinner);
            ArrayAdapter<String> bloodadapter = new ArrayAdapter<String>(FeedActivity.this,
                    android.R.layout.simple_spinner_dropdown_item) {

                @Override
                public View getView(int position, View convertView, ViewGroup parent) {

                    View v = super.getView(position, convertView, parent);
                    if (position == getCount()) {
                        ((TextView) v.findViewById(android.R.id.text1)).setText("");
                        ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
                    }

                    return v;
                }

                @Override
                public int getCount() {
                    return super.getCount() - 1; // you dont display last item. It is used as hint.
                }

            };

            bloodadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            bloodadapter.add("O");
            bloodadapter.add("A");
            bloodadapter.add("B");
            bloodadapter.add("AB");
            bloodadapter.add("Desired Type");

            bloodspinner.setAdapter(bloodadapter);
            bloodspinner.setSelection(bloodadapter.getCount()); //display hint

            //Buttons-Editexts
            Button btnpost = (Button) d.findViewById(R.id.post);
            final EditText userInput = (EditText) d.findViewById(R.id.editTextDialogUserInput);

            d.show();

            btnpost.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (bloodspinner.getSelectedItem().toString().equals("Desired Type")) {
                        Toast.makeText(getApplicationContext(), "Input Blood Type!", Toast.LENGTH_SHORT).show();
                    } else if (rhesusspinner.getSelectedItem().toString().equals("Rhesus")) {
                        Toast.makeText(getApplicationContext(), "Input Rhesus!", Toast.LENGTH_SHORT).show();
                    } else if (userInput.getText().toString().equals("")) {
                        Toast.makeText(getApplicationContext(), "Input your request message!",
                                Toast.LENGTH_SHORT).show();
                    } else {

                        int uid = session.currentUID();

                        String message = userInput.getText().toString();
                        String post_bloodtype = bloodspinner.getSelectedItem().toString();
                        String post_rhesus = rhesusspinner.getSelectedItem().toString();

                        NetAsync(d, view, uid, message, post_bloodtype, post_rhesus);

                    }
                }
            });

        }
    });

    //        // We first check for cached request
    //        Cache cache = FeedController.getInstance().getRequestQueue().getCache();
    //        Entry entry = cache.get(URL_FEED);
    //        if (entry != null) {
    //            // fetch the data from cache
    //            try {
    //                String data = new String(entry.data, "UTF-8");
    //                try {
    //                    parseJsonFeed(new JSONObject(data));
    //                } catch (JSONException e) {
    //                    e.printStackTrace();
    //                }
    //            } catch (UnsupportedEncodingException e) {
    //                e.printStackTrace();
    //            }
    //
    //        } else {
    // making fresh volley request and getting json

    /**
     * Showing Swipe Refresh animation on activity create
     * As animation won't start on onCreate, post runnable is used
     */
    swipeRefreshLayout.post(new Runnable() {
        @Override
        public void run() {
            swipeRefreshLayout.setRefreshing(true);
            getTimelineAsync();
        }
    });

}