Example usage for android.widget RadioGroup setVisibility

List of usage examples for android.widget RadioGroup setVisibility

Introduction

In this page you can find the example usage for android.widget RadioGroup setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:com.markupartist.sthlmtraveling.PlannerFragment.java

public void initViews() {
    mSearchView = getActivity().getLayoutInflater().inflate(R.layout.search, null);
    getListView().addHeaderView(mSearchView, null, false);

    final TextView historyView = (TextView) getActivity().getLayoutInflater().inflate(R.layout.header, null);
    historyView.setText(R.string.history_label);
    historyView.setOnClickListener(null); // Makes the header un-clickable, hack!
    getListView().addHeaderView(historyView);

    // Hide dividers on the header view.
    getListView().setHeaderDividersEnabled(false);

    if (!mStartPoint.hasName()) {
        mStartPoint.setName(Site.TYPE_MY_LOCATION);
    }//from w w w .  j a v  a  2s .  c  o  m
    mStartPointAutoComplete = createAutoCompleteTextView(R.id.from, /*R.id.from_progress*/ -1, mStartPoint);
    mEndPointAutoComplete = createAutoCompleteTextView(R.id.to, /*R.id.to_progress*/ -1, mEndPoint);
    mViaPointAutoComplete = createAutoCompleteTextView(R.id.via, /*R.id.via_progress*/ -1, mViaPoint, true);

    try {
        mHistoryDbAdapter = new HistoryDbAdapter(getActivity()).open();
    } catch (final Exception e) {
        showDialog(createDialogReinstallApp());
        return;
    }

    // Setup view for choosing other data for start and end point.
    final ImageButton fromDialog = (ImageButton) mSearchView.findViewById(R.id.from_menu);
    fromDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            mStartPointAutoComplete.setError(null);
            showDialog(createDialogStartPoint());
        }
    });
    final ImageButton toDialog = (ImageButton) mSearchView.findViewById(R.id.to_menu);
    toDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            mEndPointAutoComplete.setError(null);
            showDialog(createDialogEndPoint());
        }
    });
    final ImageButton viaDialog = (ImageButton) mSearchView.findViewById(R.id.via_menu);
    viaDialog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            mViaPointAutoComplete.setError(null);
            showDialog(createDialogViaPoint());
        }
    });
    // Views for date and time
    mChangeTimeLayout = (LinearLayout) mSearchView.findViewById(R.id.planner_change_time_layout);

    mDateButton = (Button) mSearchView.findViewById(R.id.planner_route_date);
    mDateButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            showDialog(createDialogDate());
        }
    });

    mTimeButton = (Button) mSearchView.findViewById(R.id.planner_route_time);
    mTimeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            showDialog(createDialogTime());
        }
    });

    // Views for radio buttons
    final RadioButton nowRadioButton = (RadioButton) mSearchView.findViewById(R.id.planner_check_now);
    nowRadioButton.setOnCheckedChangeListener(this);
    final RadioButton laterRadioButton = (RadioButton) mSearchView
            .findViewById(R.id.planner_check_more_choices);
    laterRadioButton.setOnCheckedChangeListener(this);

    mWhenSpinner = (Spinner) mSearchView.findViewById(R.id.departure_arrival_choice);
    final ArrayAdapter<CharSequence> whenChoiceAdapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.when_choice, android.R.layout.simple_spinner_item);
    whenChoiceAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mWhenSpinner.setAdapter(whenChoiceAdapter);

    // Handle create shortcut.
    if (mCreateShortcut) {
        registerScreen("Planner create shortcut");
        getActivity().setTitle(R.string.create_shortcut_label);

        // Add search label to button

        RadioGroup chooseTimeGroup = (RadioGroup) mSearchView.findViewById(R.id.planner_choose_time_group);
        chooseTimeGroup.setVisibility(View.GONE);
        historyView.setVisibility(View.GONE);
        // Fake an adapter. This needs to be fixed later on so we can use the history.
        setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.journey_history_row));
    } else {
        setListAdapter(mAdapter);
    }
}

From source file:com.gpsmobitrack.gpstracker.MenuItems.SettingsPage.java

/**
 * Show frequency dialog//  w  w  w.  j  a v  a  2 s.c o  m
 */
private void showFrequencyPurchaseDialog(final int value) {
    final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.alert_dialog_main);
    final TextView alertTitle = (TextView) dialog.findViewById(R.id.alert_title);
    final TextView alertMsg = (TextView) dialog.findViewById(R.id.alert_msg);
    final EditText alertEditTxt = (EditText) dialog.findViewById(R.id.alert_edit_txt);
    Button okBtn = (Button) dialog.findViewById(R.id.alert_ok_btn);
    Button cancelBtn = (Button) dialog.findViewById(R.id.alert_cancel_btn);
    final RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.myRadioGroup);

    final RadioButton radioOneMonth = (RadioButton) dialog.findViewById(R.id.oneMonth);
    final RadioButton radioThreeMonth = (RadioButton) dialog.findViewById(R.id.threeMonth);
    final RadioButton radioSixMonth = (RadioButton) dialog.findViewById(R.id.sixMonth);
    final RadioButton radioOneYear = (RadioButton) dialog.findViewById(R.id.oneYear);

    //long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL);
    radioGroup.setVisibility(View.VISIBLE);
    alertTitle.setText("Purchase Product");
    if (value == updateDurationValue[0]) {
        alertMsg.setText("Buy Update Frequency for 1 Minutes");
        //radioOneMonth.setChecked(true);
        if (userType == PurchaseStatus.FULL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    } else if (value == updateDurationValue[1]) {
        alertMsg.setText("Buy Update Frequency for 2 Minutes");
        if (userType == PurchaseStatus.SEMI_FULL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    } else if (value == updateDurationValue[2]) {
        alertMsg.setText("Buy Update Frequency for 3 Minutes");

        if (userType == PurchaseStatus.PARTIAL_ACCESS_USER) {
            if (duration.equalsIgnoreCase("OneMonth")) {
                radioOneMonth.setChecked(true);
            } else {
                radioOneMonth.setChecked(false);
                ;
            }
            if (duration.equalsIgnoreCase("ThreeMonth")) {
                radioThreeMonth.setChecked(true);
            } else {
                radioThreeMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("SixMonth")) {
                radioSixMonth.setChecked(true);
            } else {
                radioSixMonth.setChecked(false);
            }
            if (duration.equalsIgnoreCase("OneYear")) {
                radioOneYear.setChecked(true);
            } else {
                radioOneYear.setChecked(false);
            }
        }
    }
    alertEditTxt.setVisibility(View.GONE);

    radioOneMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH;
            }
        }
    });
    radioThreeMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH;
            }
        }
    });
    radioSixMonth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH;
            }
        }
    });
    radioOneYear.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (value == updateDurationValue[0]) {
                purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR;
            } else if (value == updateDurationValue[1]) {
                purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR;
            } else if (value == updateDurationValue[2]) {
                purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR;
            }
        }
    });
    cancelBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL);

            // Set Spinner
            setSpinnerUpdateTime(updateTime);
            firstSelect = false;
        }
    });
    okBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            if (radioOneMonth.isChecked() || radioThreeMonth.isChecked() || radioSixMonth.isChecked()
                    || radioOneYear.isChecked()) {
                // One min update
                if (value == updateDurationValue[0] && radioOneMonth.isChecked()) {
                    fullPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioThreeMonth.isChecked()) {
                    fullPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioSixMonth.isChecked()) {
                    fullPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[0] && radioOneYear.isChecked()) {
                    fullPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }
                // Two min update
                else if (value == updateDurationValue[1] && radioOneMonth.isChecked()) {
                    semiparticalPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioThreeMonth.isChecked()) {
                    semiparticalPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioSixMonth.isChecked()) {
                    semiparticalPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[1] && radioOneYear.isChecked()) {
                    semiparticalPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }
                // Three min update
                else if (value == updateDurationValue[2] && radioOneMonth.isChecked()) {
                    particalPurchaseOneMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioThreeMonth.isChecked()) {
                    particalPurchaseThreeMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioSixMonth.isChecked()) {
                    particalPurchaseSixMonth();
                    purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH;
                    //startUpdatePurchaseStatus();
                } else if (value == updateDurationValue[2] && radioOneYear.isChecked()) {
                    particalPurchaseOneYear();
                    purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR;
                    //startUpdatePurchaseStatus();
                }

                long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF,
                        AppConstants.DEFAULT_TIME_INTERVAL);
                // Set Spinner
                setSpinnerUpdateTime(updateTime);
                firstSelect = false;
                dialog.dismiss();
            } else {
                dialog.show();
                Utils.showToast("Select durations");
                //Toast.makeText(getActivity(), "Select durations", Toast.LENGTH_LONG).show();
            }
        }
    });
    dialog.show();
}

From source file:de.da_sense.moses.client.FormFragment.java

/**
 * Displays a single choice question to the user.
 * @param question the question to be displayed
 * @param linearLayoutInsideAScrollView the view to add the question to
 * @param ordinal the ordinal number of the question i.e. 1, 2, 3, 4 or 5
 *//*from   w  ww. j  a  v a2  s  .  c  om*/
private void makeSingleChoice(final Question question, LinearLayout linearLayoutInsideAScrollView,
        int ordinal) {
    LinearLayout questionContainer = generateQuestionContainer(linearLayoutInsideAScrollView);
    String questionText = question.getTitle();
    List<PossibleAnswer> possibleAnswers = question.getPossibleAnswers();
    Collections.sort(possibleAnswers);

    TextView questionView = new TextView(getActivity());
    questionView.setText(ordinal + ". " + questionText);
    if (question.isMandatory())
        questionView.setTextAppearance(getActivity(), R.style.QuestionTextStyleMandatory);
    else
        questionView.setTextAppearance(getActivity(), R.style.QuestionTextStyle);
    questionContainer.addView(questionView);
    mQuestionTitleMappings.put(question, questionView);

    final RadioButton[] rb = new RadioButton[possibleAnswers.size()];
    RadioGroup rg = new RadioGroup(getActivity()); // create the RadioGroup
    rg.setOrientation(RadioGroup.VERTICAL);// or RadioGroup.VERTICAL
    String madeAnswer = question.getAnswer();
    int madeAnswerInt = -1;
    if (!madeAnswer.equals(Question.ANSWER_UNANSWERED))
        madeAnswerInt = Integer.parseInt(madeAnswer);

    for (int i = 0; i < rb.length; i++) {
        rb[i] = new RadioButton(getActivity());
        if (i % 2 == 0)
            rb[i].setBackgroundColor(getActivity().getResources().getColor(R.color.light_gray));
        rg.addView(rb[i]); // the RadioButtons are added to the radioGroup
        // instead of the layout
        PossibleAnswer possibleAnswer = possibleAnswers.get(i);
        rb[i].setText(possibleAnswer.getTitle());
        final int possibleAnswerId = possibleAnswer.getId();
        if (madeAnswerInt == possibleAnswerId)
            rb[i].setChecked(true);
        rb[i].setTextAppearance(getActivity(), R.style.PossibleAnswerTextStyle);
        LayoutParams rowParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        rb[i].setLayoutParams(rowParam);

        // click handling
        rb[i].setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                question.setAnswer(String.valueOf(possibleAnswerId));
            }
        });
        if (mBelongsTo == WelcomeActivityPagerAdapter.TAB_HISTORY)
            rb[i].setEnabled(false);

        rb[i].setVisibility(View.VISIBLE);
    }

    rg.setVisibility(View.VISIBLE);
    if (mBelongsTo == WelcomeActivityPagerAdapter.TAB_HISTORY)
        rg.setEnabled(false);
    Log.i(LOG_TAG, "last rg = " + rg);
    questionContainer.addView(rg);
}

From source file:at.flack.MailMainActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    prefs = getActivity().getSharedPreferences("mail", Context.MODE_PRIVATE);
    if (!prefs.getString("mailaddress", "").equals("")) {
        View rootView = inflater.inflate(R.layout.fragment_mail_main, container, false);

        loadmore = new LoadMoreAdapter(inflater.inflate(R.layout.contacts_loadmore, contactList, false));
        contactList = (ListView) rootView.findViewById(R.id.listview);
        TextView padding = new TextView(getActivity());
        padding.setHeight(10);//from   www .jav a 2 s. c  om
        contactList.addHeaderView(padding);
        contactList.setHeaderDividersEnabled(false);
        contactList.addFooterView(loadmore.getView(), null, false);
        contactList.setFooterDividersEnabled(false);
        progressbar = rootView.findViewById(R.id.load_screen);
        FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
        fab.attachToListView(contactList);
        fab.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent newMail = new Intent(getActivity(), NewMailActivity.class);
                getActivity().startActivity(newMail);
            }
        });

        progressbar = rootView.findViewById(R.id.load_screen);
        if (MainActivity.getMailcontacts() == null)
            progressbar.setVisibility(View.VISIBLE);
        updateContactList(((MainActivity) this.getActivity()));

        swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
        swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                if (getActivity() instanceof MainActivity) {
                    MainActivity.mailprofile = null;
                    ((MainActivity) getActivity()).emailLogin(1, 0, limit);
                }

            }
        });
        contactList.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0
                        : contactList.getChildAt(0).getTop();
                swipe.setEnabled(topRowVerticalPosition >= 0);
            }
        });

        contactList.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                if (MainActivity.getListItems() == null) {
                    updateContactList((MainActivity) getActivity());
                }
                openMessageActivity(getActivity(), arg2 - 1);
            }

        });

        loadmore.getView().setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                loadmore.setEnabled(false);
                MainActivity.mailprofile = null;
                limit += 12;
                ((MainActivity) getActivity()).emailLogin(1, 0, limit);
            }
        });

        setRetainInstance(true);
        return rootView;
    } else {
        View rootView = inflater.inflate(R.layout.fragment_email_login, container, false);
        final EditText mail = (EditText) rootView.findViewById(R.id.email);
        final EditText password = (EditText) rootView.findViewById(R.id.password);

        final EditText host = (EditText) rootView.findViewById(R.id.host);
        final EditText port = (EditText) rootView.findViewById(R.id.port);
        final EditText smtphost = (EditText) rootView.findViewById(R.id.smtphost);
        final EditText smtpport = (EditText) rootView.findViewById(R.id.smtpport);

        final Button login_button = (Button) rootView.findViewById(R.id.login_button);

        final RadioGroup radioGroup = (RadioGroup) rootView.findViewById(R.id.radioGroup);
        final RadioButton imap = (RadioButton) rootView.findViewById(R.id.radioButtonImap);

        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                host.setVisibility(View.VISIBLE);
                port.setVisibility(View.VISIBLE);
                smtphost.setVisibility(View.VISIBLE);
                smtpport.setVisibility(View.VISIBLE);
            }
        });

        login_button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int at = mail.getText().toString().indexOf("@");
                int dot = mail.getText().toString().lastIndexOf(".");
                if (mail.getText().length() <= 0 || at < 0 || dot < 0) {
                    Toast.makeText(MailMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_mail),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
                if (password.getText().length() <= 0) {
                    Toast.makeText(MailMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_pw),
                            Toast.LENGTH_SHORT).show();
                    return;
                }

                String hostPart = mail.getText().toString().substring(at + 1, dot);

                MailAccounts mailacc = null;
                try {
                    mailacc = MailAccounts.valueOf(hostPart.toUpperCase(Locale.GERMAN));
                } catch (IllegalArgumentException e) {
                }
                if (mailacc == null) {
                    radioGroup.setVisibility(View.VISIBLE);
                    if (host.getText().toString().isEmpty() || port.getText().toString().isEmpty()
                            || smtphost.getText().toString().isEmpty()
                            || smtpport.getText().toString().isEmpty()) {
                        Toast.makeText(MailMainActivity.this.getActivity(),
                                MailMainActivity.this.getActivity().getResources().getString(
                                        R.string.activity_mail_enter_more_information),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                    prefs.edit().putString("mailsmtp", smtphost.getText().toString()).apply();
                    prefs.edit().putInt("mailsmtpport", Integer.parseInt(smtpport.getText().toString()));
                    prefs.edit().putString("mailimap", host.getText().toString()).apply();
                    prefs.edit().putInt("mailimapport", Integer.parseInt(port.getText().toString())).apply();
                    prefs.edit().putBoolean("mailuseimap", imap.isChecked()).apply();
                }

                login_button.setEnabled(false);
                login_button.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
                prefs.edit().putString("mailaddress", mail.getText().toString()).apply();
                prefs.edit().putString("mailpassword", password.getText().toString()).apply();

                if (mailacc != null) {
                    prefs.edit().putString("mailsmtp", mailacc.getSmtpHost()).apply();
                    prefs.edit().putInt("mailsmtpport", mailacc.getSMTPPort());
                    prefs.edit().putString("mailimap", mailacc.getHost()).apply();
                    prefs.edit().putInt("mailimapport", mailacc.getPort()).apply();
                    prefs.edit().putBoolean("mailuseimap", true).apply();
                }

                prefs.edit().commit();
                ((MainActivity) getActivity()).emailLogin(0);
            }
        });

        setRetainInstance(true);

        return rootView;
    }
}

From source file:universe.constellation.orion.viewer.OrionViewerActivity.java

public void initRotationScreen() {
    //if (getDevice() instanceof EdgeDevice) {
    if (false) {//from  ww w  . ja va 2s  . c  om
        final RadioGroup rotationGroup = (RadioGroup) findMyViewById(R.id.rotationGroup);

        rotationGroup.check(R.id.rotate0);

        if (Device.Info.NOOK2) {
            RadioButton r0 = (RadioButton) rotationGroup.findViewById(R.id.rotate0);
            RadioButton r90 = (RadioButton) rotationGroup.findViewById(R.id.rotate90);
            RadioButton r270 = (RadioButton) rotationGroup.findViewById(R.id.rotate270);
            TextView tv = (TextView) findMyViewById(R.id.navigation_title);
            int color = tv.getTextColors().getDefaultColor();
            r0.setTextColor(color);
            r90.setTextColor(color);
            r270.setTextColor(color);
        }

        getSubscriptionManager().addDocListeners(new DocumentViewAdapter() {
            @Override
            public void documentOpened(Controller controller) {
                updateRotation();
            }
        });

        ImageButton apply = (ImageButton) findMyViewById(R.id.rotation_apply);
        apply.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                onApplyAction(true);
                int id = rotationGroup.getCheckedRadioButtonId();
                controller.setRotation(id == R.id.rotate0 ? 0 : id == R.id.rotate90 ? -1 : 1);
            }
        });

        ListView list = (ListView) findMyViewById(R.id.rotationList);
        list.setVisibility(View.GONE);
    } else {
        RadioGroup rotationGroup = (RadioGroup) findMyViewById(R.id.rotationGroup);
        rotationGroup.setVisibility(View.GONE);

        final ListView list = (ListView) findMyViewById(R.id.rotationList);

        //set choices and replace 0 one with Application Default
        boolean isLevel9 = getOrionContext().getSdkVersion() >= 9;
        CharSequence[] values = getResources().getTextArray(
                isLevel9 ? R.array.screen_orientation_full_desc : R.array.screen_orientation_desc);
        CharSequence[] newValues = new CharSequence[values.length];
        for (int i = 0; i < values.length; i++) {
            newValues[i] = values[i];
        }
        newValues[0] = getResources().getString(R.string.orientation_default_rotation);

        list.setAdapter(Device.Info.NOOK2
                ? new Nook2ListAdapter(this, android.R.layout.simple_list_item_single_choice, newValues,
                        (TextView) findMyViewById(R.id.navigation_title))
                : new ArrayAdapter(this, android.R.layout.simple_list_item_single_choice, newValues));

        list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        list.setItemChecked(0, true);

        list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
            public void onItemClick(android.widget.AdapterView parent, View view, int position, long id) {
                CheckedTextView check = (CheckedTextView) view;
                check.setChecked(!check.isChecked());
            }
        });

        final CharSequence[] ORIENTATION_ARRAY = getResources().getTextArray(R.array.screen_orientation_full);

        list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
            public void onItemClick(android.widget.AdapterView parent, View view, int position, long id) {
                onApplyAction(true);
                String orientation = ORIENTATION_ARRAY[position].toString();
                controller.changeOrinatation(orientation);
            }
        });

        ImageButton apply = (ImageButton) findMyViewById(R.id.rotation_apply);
        apply.setVisibility(View.GONE);
        //            apply.setOnClickListener(new View.OnClickListener() {
        //                public void onClick(View view) {
        //                    onApplyAction(true);
        //                }
        //            });
    }

    ImageButton cancel = (ImageButton) findMyViewById(R.id.rotation_close);
    cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onAnimatorCancel();
            updateRotation();
        }
    });
}