Example usage for android.widget Checkable toggle

List of usage examples for android.widget Checkable toggle

Introduction

In this page you can find the example usage for android.widget Checkable toggle.

Prototype

void toggle();

Source Link

Document

Change the checked state of the view to the inverse of its current state

Usage

From source file:com.battlelancer.seriesguide.ui.dialogs.ListsDialogFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Checkable checkable = (Checkable) view;
    checkable.toggle();
    mAdapter.setItemChecked(position, checkable.isChecked());
}

From source file:com.xixicm.de.presentation.view.adapter.SentenceDetailPageAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = mInflater.inflate(R.layout.sentence_detail, null);
    final Sentence sentence = mSentences.get(position);
    JSONObject content = sentence.getJsonObjectContent();
    final Checkable checkable = (Checkable) view.findViewById(R.id.content);
    checkable.setChecked(sentence.getIsStar());
    final CheckableImageView favoriteBtn = (CheckableImageView) view.findViewById(R.id.favorite);
    favoriteBtn.setOnClickListener(new View.OnClickListener() {
        @Override/*from www.j  a  v  a 2  s  . c  o  m*/
        public void onClick(View v) {
            checkable.toggle();
            if (mFavoriteClickListener != null) {
                mFavoriteClickListener.onFavoriteClick(sentence, checkable.isChecked());
            }
        }
    });
    ((TextView) view.findViewById(R.id.day)).setText(sentence.getDateline());
    ((TextView) view.findViewById(R.id.en_content)).setText("  " + sentence.getContent());
    ((TextView) view.findViewById(R.id.cn_content)).setText("  " + content.optString("note"));
    loadImg(sentence, (NetworkImageView) view.findViewById(R.id.image));
    container.addView(view);
    return view;
}