Example usage for android.widget Checkable isChecked

List of usage examples for android.widget Checkable isChecked

Introduction

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

Prototype

boolean isChecked();

Source Link

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();/*from w  ww  .j a v a 2s  . c o  m*/
    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 2s . 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;
}