Example usage for android.widget Switch setTextOff

List of usage examples for android.widget Switch setTextOff

Introduction

In this page you can find the example usage for android.widget Switch setTextOff.

Prototype

public void setTextOff(CharSequence textOff) 

Source Link

Document

Sets the text displayed when the button is not in the checked state.

Usage

From source file:android.support.v14.preference.SwitchPreference.java

private void syncSwitchView(View view) {
    if (view instanceof Switch) {
        final Switch switchView = (Switch) view;
        switchView.setOnCheckedChangeListener(null);
    }//  w  ww  .  j  ava  2s . c o  m
    if (view instanceof Checkable) {
        ((Checkable) view).setChecked(mChecked);
    }
    if (view instanceof Switch) {
        final Switch switchView = (Switch) view;
        switchView.setTextOn(mSwitchOn);
        switchView.setTextOff(mSwitchOff);
        switchView.setOnCheckedChangeListener(mListener);
    }
}

From source file:com.urbantamil.projmadurai.CustomWebViewClient.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.book_detail, container, false);
    final View book_use_pdf = rootView.findViewById(R.id.book_use_pdf);
    setHasOptionsMenu(true);//from   ww w  .  j  a  v a2  s  .  c o  m
    // book-use-PDF is not featured for the app
    book_use_pdf.setVisibility(View.INVISIBLE);

    if (getArguments().containsKey(ARG_ITEM_OPEN)) {
        m_open_book = getArguments().getBoolean(ARG_ITEM_OPEN);
        Log.d(TAG, "ARG_ITEM_OPEN was requested as " + m_open_book);
    }

    // Show the dummy content as text in a TextView.
    if (mItem != null) {
        ((TextView) rootView.findViewById(R.id.book_detail)).setText(mItem.getTitle());
        ((TextView) rootView.findViewById(R.id.book_author)).setText(mItem.getAuthor());
        ((CheckBox) rootView.findViewById(R.id.book_use_pdf)).setChecked(true);
        ((TextView) rootView.findViewById(R.id.book_genre)).setText(mItem.getGenre());

        final Switch sw = (Switch) rootView.findViewById(R.id.book_bookmark);
        if (Build.VERSION.SDK_INT >= 14) {
            sw.setTextOn(getResources().getString(R.string.mark));
            sw.setTextOff(getResources().getString(R.string.clear));
        }

        //load current state of bookmarking for the book
        boolean isBookMarked = false;
        try {
            MaduraiBookmark mgr = MaduraiBookmark.getManager(getActivity());
            if (mgr != null) {
                isBookMarked = mgr.findBook(mItem) >= 0;
            }
        } catch (Exception e) {
            //pass
        }

        if (Build.VERSION.SDK_INT >= 14) {
            sw.setChecked(isBookMarked);
        }

        sw.postInvalidate();
        sw.setOnClickListener(m_bookmarkListener);
        final Button btn = (Button) rootView.findViewById(R.id.book_open_browser);
        mWebView = (ObservableWebView) rootView.findViewById(R.id.book_webView);

        final ObservableWebView wv = (ObservableWebView) rootView.findViewById(R.id.book_webView);

        wv.getSettings().setJavaScriptEnabled(true);
        fontSize = wv.getSettings().getDefaultFontSize();

        wv.setKeepScreenOn(true);

        wv.setWebViewClient(new CustomWebViewClient(btn));
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = MaduraiOrg.getFullUrlAssetsHTML(mItem.getUrl_html().next());

                //update book : on recent list
                MaduraiRecentBook.getManager(getActivity()).add(mItem);

                wv.setVisibility(View.VISIBLE);
                wv.invalidate();
                wv.loadUrl(url);

                btn.setEnabled(false);
                btn.setText(R.string.projmad_please_wait);
            }
        });

        wv.setOnScrollChangedCallback(new ObservableWebView.OnScrollChangedCallback() {
            public void onScroll(int l, int t) {
                //Do stuff
                Log.d(TAG, "We Scrolled by " + l + " and t = " + t);
            }
        });

        if (m_open_book) {
            Log.d(TAG, "Book requested to be opened");
            // delayed open book
            wv.setVisibility(View.VISIBLE);
            wv.invalidate();
            String url = MaduraiOrg.getFullUrlAssetsHTML(mItem.getUrl_html().next());
            wv.loadUrl(url);
        } else {
            Log.d(TAG, "Book requested cannot be opened");
        }
    } else {
        Log.d(TAG, "mItem - cannot be loaded - some error occured on dispatch");
    }

    return rootView;
}

From source file:net.opendasharchive.openarchive.ReviewMediaActivity.java

private void deleteMedia() {
    final Switch swDeleteLocal = new Switch(this);
    final Switch swDeleteRemote = new Switch(this);

    LinearLayout linearLayoutGroup = new LinearLayout(this);
    linearLayoutGroup.setOrientation(LinearLayout.VERTICAL);
    linearLayoutGroup.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    swDeleteLocal.setTextOn(getString(R.string.answer_yes));
    swDeleteLocal.setTextOff(getString(R.string.answer_no));

    TextView tvLocal = new TextView(this);
    tvLocal.setText(R.string.delete_local);

    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    linearLayout.setGravity(Gravity.CENTER_HORIZONTAL);

    linearLayout.addView(tvLocal);/*from   w  w  w. j av a  2s  .  c o  m*/
    linearLayout.addView(swDeleteLocal);

    linearLayoutGroup.addView(linearLayout);

    if (mMedia.getServerUrl() != null) {
        swDeleteRemote.setTextOn(getString(R.string.answer_yes));
        swDeleteRemote.setTextOff(getString(R.string.answer_no));

        TextView tvRemote = new TextView(this);
        tvRemote.setText(R.string.delete_remote);

        LinearLayout linearLayoutRemote = new LinearLayout(this);
        linearLayoutRemote.setOrientation(LinearLayout.HORIZONTAL);
        linearLayoutRemote.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        linearLayoutRemote.setGravity(Gravity.CENTER_HORIZONTAL);

        linearLayoutRemote.addView(tvRemote);
        linearLayoutRemote.addView(swDeleteRemote);
        linearLayoutGroup.addView(linearLayoutRemote);

    }

    AlertDialog.Builder build = new AlertDialog.Builder(ReviewMediaActivity.this).setTitle(R.string.menu_delete)
            .setMessage(R.string.alert_delete_media).setView(linearLayoutGroup).setCancelable(true)
            .setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    //do nothing
                }
            })

            .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    deleteMedia(swDeleteLocal.isChecked(), swDeleteRemote.isChecked());
                    finish();

                }
            });

    build.create().show();
}