Example usage for android.widget ImageView setOnClickListener

List of usage examples for android.widget ImageView setOnClickListener

Introduction

In this page you can find the example usage for android.widget ImageView setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:nuclei.ui.view.media.PlayerControlsView.java

private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    setClickable(true);/*from  w  ww. ja  va  2 s  . c o  m*/
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PlayerControlsView, defStyleAttr,
            defStyleRes);

    mAutoHide = a.getBoolean(R.styleable.PlayerControlsView_auto_hide, false);
    boolean bottom = a.getBoolean(R.styleable.PlayerControlsView_bottom, false);

    int layout = a.getResourceId(R.styleable.PlayerControlsView_control_layout,
            bottom ? R.layout.cyto_view_player_controls_bottom : R.layout.cyto_view_player_controls);

    boolean hasPrevious = a.getBoolean(R.styleable.PlayerControlsView_has_previous, true);
    boolean hasNext = a.getBoolean(R.styleable.PlayerControlsView_has_next, true);

    boolean hasRewind = a.getBoolean(R.styleable.PlayerControlsView_has_rewind, false);
    boolean hasFastforward = a.getBoolean(R.styleable.PlayerControlsView_has_fastforward, false);

    a.recycle();

    View view = LayoutInflater.from(context).inflate(layout, this, false);
    addView(view);

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mMediaInterface != null) {
                if (v.getId() == R.id.btn_play) {
                    if (mMediaInterface.getPlayerController() != null) {
                        v.setActivated(!v.isActivated());
                        if (v.isActivated())
                            mMediaInterface.getPlayerController().start();
                        else
                            mMediaInterface.getPlayerController().pause();
                    }
                } else if (v.getId() == R.id.btn_speed) {
                    onSpeedSelected(v);
                } else if (v.getId() == R.id.btn_timer) {
                    onTimerSelected(v);
                } else if (mMediaInterface.getMediaController() != null) {
                    if (mMediaInterface.getPlayerController() != null) {
                        if (v.getId() == R.id.btn_previous)
                            mMediaInterface.getPlayerController().skipToPrevious();
                        else if (v.getId() == R.id.btn_next)
                            mMediaInterface.getPlayerController().skipToNext();
                        else if (v.getId() == R.id.btn_rewind)
                            mMediaInterface.getPlayerController().rewind();
                        else if (v.getId() == R.id.btn_fastforward)
                            mMediaInterface.getPlayerController().fastForward();
                    }
                }
            }
        }
    };

    view.findViewById(R.id.btn_play).setOnClickListener(listener);

    ImageView previous = (ImageView) view.findViewById(R.id.btn_previous);
    ImageView next = (ImageView) view.findViewById(R.id.btn_next);
    ImageView rewind = (ImageView) view.findViewById(R.id.btn_rewind);
    ImageView fastforward = (ImageView) view.findViewById(R.id.btn_fastforward);

    if (previous != null) {
        previous.setOnClickListener(listener);
        previous.setVisibility(hasPrevious ? VISIBLE : GONE);
    }

    if (next != null) {
        next.setOnClickListener(listener);
        next.setVisibility(hasNext ? VISIBLE : GONE);
    }

    if (rewind != null) {
        rewind.setOnClickListener(listener);
        rewind.setVisibility(hasRewind ? VISIBLE : GONE);
    }

    if (fastforward != null) {
        fastforward.setOnClickListener(listener);
        fastforward.setVisibility(hasFastforward ? VISIBLE : GONE);
    }

    DefaultCallback.onHandleState(this, fastforward, rewind, next, previous, null);

    TextView speed = ((TextView) view.findViewById(R.id.btn_speed));
    if (speed != null) {
        speed.setText(ResourceProvider.getInstance().getSelectedSpeed());
        speed.setOnClickListener(listener);
        speed.setVisibility(View.VISIBLE);
    }

    TextView timer = (TextView) view.findViewById(R.id.btn_timer);
    if (timer != null) {
        timer.setText(ResourceProvider.getInstance().getString(ResourceProvider.TIMER));
        timer.setOnClickListener(listener);
    }
}

From source file:com.githang.androidkit.app.IntroActivity.java

/**
 * /* www .  j  a v a  2 s.co  m*/
 */
private void createContentView() {
    // ?
    mIntroResource = new IntroResource();
    setIntroViews(mIntroResource);

    // 
    RelativeLayout rootView = new RelativeLayout(this);
    rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // 
    mViewPager = new ViewPager(this);
    RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    rootView.addView(mViewPager, pagerParams);

    // 
    LinearLayout indicatorLayout = new LinearLayout(this);
    RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom;
    indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    indicatorLayout.setLayoutParams(indicatorParams);
    indicatorLayout.setOrientation(LinearLayout.HORIZONTAL);

    // 
    int indicatorCount = mIntroResource.views.size();
    int padding = mIntroResource.indicatorImagePadding;
    mIndicator = new ArrayList<ImageView>();
    for (int i = 0; i < indicatorCount; i++) {
        ImageView imageView = new ImageView(this);
        LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        imageView.setPadding(padding, padding, padding, padding);
        imageView.setClickable(true);
        imageView.setOnClickListener(this);
        imageView.setImageResource(mIntroResource.indicatorNoSelectedId);
        imageView.setTag(i);
        mIndicator.add(imageView);
        indicatorLayout.addView(imageView, imageParams);
    }

    rootView.addView(indicatorLayout);

    setContentView(rootView);
}

From source file:com.lurencun.cfuture09.androidkit.uilibs.IntroActivity.java

/**
 * // w  w  w . j av  a 2  s. co  m
 */
private void createContentView() {
    // ?
    mIntroResource = new IntroResource();
    setIntroViews(mIntroResource);

    // 
    RelativeLayout rootView = new RelativeLayout(this);
    rootView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    // 
    mViewPager = new ViewPager(this);
    RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
    rootView.addView(mViewPager, pagerParams);

    // 
    LinearLayout indicatorLayout = new LinearLayout(this);
    RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom;
    indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    indicatorLayout.setLayoutParams(indicatorParams);
    indicatorLayout.setOrientation(LinearLayout.HORIZONTAL);

    // 
    int indicatorCount = mIntroResource.views.size();
    int padding = mIntroResource.indicatorImagePadding;
    mIndicator = new ArrayList<ImageView>();
    for (int i = 0; i < indicatorCount; i++) {
        ImageView imageView = new ImageView(this);
        LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        imageView.setPadding(padding, padding, padding, padding);
        imageView.setClickable(true);
        imageView.setOnClickListener(this);
        imageView.setImageResource(mIntroResource.indicatorNoSelectedId);
        imageView.setTag(i);
        mIndicator.add(imageView);
        indicatorLayout.addView(imageView, imageParams);
    }

    rootView.addView(indicatorLayout);

    setContentView(rootView);
}

From source file:com.happynetwork.vrestate.activitys.ContactlistFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //T??home???appcrash
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;/*from www .j a  va 2 s  .c o m*/
    inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    listView = (ListView) getView().findViewById(R.id.list);
    //      sidebar = (Sidebar) getView().findViewById(R.id.sidebar);
    //      sidebar.setListView(listView);
    back = (ImageView) getView().findViewById(R.id.back);
    back.setOnClickListener(this);
    //???
    blackList = EMContactManager.getInstance().getBlackListUsernames();
    contactList = new ArrayList<User>();
    // ?contactlist
    getContactList();

    //?
    query = (EditText) getView().findViewById(R.id.query);
    query.setHint(R.string.search);
    clearSearch = (ImageButton) getView().findViewById(R.id.search_clear);
    query.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s);
            if (s.length() > 0) {
                clearSearch.setVisibility(View.VISIBLE);
            } else {
                clearSearch.setVisibility(View.INVISIBLE);

            }
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable s) {
        }
    });
    clearSearch.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            query.getText().clear();
            hideSoftKeyboard();
        }
    });

    // adapter
    adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String username = adapter.getItem(position).getUsername();
            if (Constant.NEW_FRIENDS_USERNAME.equals(username)) {
                // ?
                User user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .get(Constant.NEW_FRIENDS_USERNAME);
                user.setUnreadMsgCount(0);
                startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class));
            } else if (Constant.GROUP_USERNAME.equals(username)) {
                // ??
                startActivity(new Intent(getActivity(), GroupsActivity.class));
            } else if (Constant.CHAT_ROOM.equals(username)) {
                //??
                startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class));
            } else if (Constant.CHAT_ROBOT.equals(username)) {
                //Robot?
                startActivity(new Intent(getActivity(), RobotsActivity.class));
            } else {
                // demo??
                String userName = adapter.getItem(position).getUsername();
                startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", userName));
            }
        }
    });
    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // ??
            if (getActivity().getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });

    ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact);
    // ?
    addContactView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), AddContactActivity.class));
        }
    });

    registerForContextMenu(listView);

    //      progressBar = (View) getView().findViewById(R.id.progress_bar);

    contactSyncListener = new HXContactSyncListener();
    HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener);

    blackListSyncListener = new HXBlackListSyncListener();
    HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener);

    contactInfoSyncListener = new HXContactInfoSyncListener();
    ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager()
            .addSyncContactInfoListener(contactInfoSyncListener);
    boolean ll = HXSDKHelper.getInstance().isContactsSyncedWithServer();
    //      if (!ll) {
    //         progressBar.setVisibility(View.VISIBLE);
    //      } else {
    //         progressBar.setVisibility(View.GONE);
    //      }
}

From source file:eu.iescities.pilot.rovereto.roveretoexplorer.custom.CommentsHandler.java

/**
 * @param ctx//from w w  w  .  j a v a 2s.c o m
 * @param toggle
 * @param container
 */
public CommentsHandler(BaseDTObject object, FragmentActivity activity, View main) {
    super();
    this.activity = activity;
    this.main = main;

    TextView toggle = (TextView) main.findViewById(R.id.comments_tv);
    ImageView toggleButton = (ImageView) main.findViewById(R.id.comments_button);
    Button rateButton = (Button) main.findViewById(R.id.rate_button);
    this.object = object;

    OnClickListener commentsListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            commentsVisible = !commentsVisible;
            if (commentsVisible) {
                loadComments();
            }
        }
    };
    toggle.setOnClickListener(commentsListener);
    toggleButton.setOnClickListener(commentsListener);

    RatingBar rating = (RatingBar) main.findViewById(R.id.rating);
    rating.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                ratingDialog();
            }
            return true;
        }
    });
    rateButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ratingDialog();
        }
    });

    updateRating();
}

From source file:com.gh4a.activities.IssueActivity.java

private void fillData() {
    // set details inside listview header
    ImageView ivGravatar = (ImageView) mListHeaderView.findViewById(R.id.iv_gravatar);
    AvatarHandler.assignAvatar(ivGravatar, mIssue.getUser());
    ivGravatar.setOnClickListener(this);

    TextView tvState = (TextView) mHeader.findViewById(R.id.tv_state);
    boolean closed = Constants.Issue.STATE_CLOSED.equals(mIssue.getState());
    int stateTextResId = closed ? R.string.closed : R.string.open;
    int stateColorAttributeId = closed ? R.attr.colorIssueClosed : R.attr.colorIssueOpen;

    tvState.setText(getString(stateTextResId).toUpperCase(Locale.getDefault()));
    transitionHeaderToColor(stateColorAttributeId,
            closed ? R.attr.colorIssueClosedDark : R.attr.colorIssueOpenDark);
    UiUtils.trySetListOverscrollColor(mRecyclerView, UiUtils.resolveColor(this, stateColorAttributeId));

    TextView tvExtra = (TextView) mListHeaderView.findViewById(R.id.tv_extra);
    tvExtra.setText(ApiHelpers.getUserLogin(this, mIssue.getUser()));

    TextView tvTimestamp = (TextView) mListHeaderView.findViewById(R.id.tv_timestamp);
    tvTimestamp.setText(StringUtils.formatRelativeTime(this, mIssue.getCreatedAt(), true));

    TextView tvTitle = (TextView) mHeader.findViewById(R.id.tv_title);
    tvTitle.setText(mIssue.getTitle());//from  w  w w .  ja  v  a 2s  .co m

    String body = mIssue.getBodyHtml();
    TextView descriptionView = (TextView) mListHeaderView.findViewById(R.id.tv_desc);
    if (!StringUtils.isBlank(body)) {
        body = HtmlUtils.format(body).toString();
        mImageGetter.bind(descriptionView, body, mIssue.getNumber());
    }
    descriptionView.setMovementMethod(UiUtils.CHECKING_LINK_METHOD);

    View milestoneGroup = mListHeaderView.findViewById(R.id.milestone_container);
    if (mIssue.getMilestone() != null) {
        TextView tvMilestone = (TextView) mListHeaderView.findViewById(R.id.tv_milestone);
        tvMilestone.setText(mIssue.getMilestone().getTitle());
        milestoneGroup.setVisibility(View.VISIBLE);
    } else {
        milestoneGroup.setVisibility(View.GONE);
    }

    View assigneeGroup = mListHeaderView.findViewById(R.id.assignee_container);
    if (mIssue.getAssignee() != null) {
        TextView tvAssignee = (TextView) mListHeaderView.findViewById(R.id.tv_assignee);
        tvAssignee.setText(mIssue.getAssignee().getLogin());

        ImageView ivAssignee = (ImageView) mListHeaderView.findViewById(R.id.iv_assignee);
        AvatarHandler.assignAvatar(ivAssignee, mIssue.getAssignee());
        ivAssignee.setOnClickListener(this);
        assigneeGroup.setVisibility(View.VISIBLE);
    } else {
        assigneeGroup.setVisibility(View.GONE);
    }

    List<Label> labels = mIssue.getLabels();
    View labelGroup = mListHeaderView.findViewById(R.id.label_container);
    if (labels != null && !labels.isEmpty()) {
        TextView labelView = (TextView) mListHeaderView.findViewById(R.id.labels);
        SpannableStringBuilder builder = new SpannableStringBuilder();

        for (Label label : labels) {
            int pos = builder.length();
            IssueLabelSpan span = new IssueLabelSpan(this, label, true);
            builder.append(label.getName());
            builder.setSpan(span, pos, pos + label.getName().length(), 0);
        }
        labelView.setText(builder);
        labelGroup.setVisibility(View.VISIBLE);
    } else {
        labelGroup.setVisibility(View.GONE);
    }

    TextView tvPull = (TextView) mListHeaderView.findViewById(R.id.tv_pull);
    if (mIssue.getPullRequest() != null && mIssue.getPullRequest().getDiffUrl() != null) {
        tvPull.setVisibility(View.VISIBLE);
        tvPull.setOnClickListener(this);
    } else {
        tvPull.setVisibility(View.GONE);
    }

    mHeader.setVisibility(View.VISIBLE);
    updateFabVisibility();
    updateCommentLockState();
}

From source file:com.odoo.addons.notes.Notes.java

private void bindRowControls(final View view, final ODataRow row) {
    ImageView imgMove = (ImageView) view.findViewById(R.id.note_move);
    if (mCurrentKey != Type.Notes)
        imgMove.setVisibility(View.GONE);
    imgMove.setOnClickListener(new View.OnClickListener() {
        @Override// ww w.  ja v  a2s  .c o  m
        public void onClick(View v) {
            moveTo(row.getInt(OColumn.ROW_ID), row);
        }
    });
}

From source file:eu.trentorise.smartcampus.trentinofamiglia.custom.CommentsHandler.java

/**
 * @param ctx/*  w  ww  .  jav a2s  . c  om*/
 * @param toggle
 * @param container
 */
public CommentsHandler(BaseDTObject object, FragmentActivity activity, View main) {
    super();
    this.activity = activity;
    this.main = main;
    if (!CategoryHelper.hasRatingForm(object)) {
        main.findViewById(R.id.rating_block).setVisibility(View.GONE);
        return;
    }
    TextView toggle = (TextView) main.findViewById(R.id.comments_tv);
    ImageView toggleButton = (ImageView) main.findViewById(R.id.comments_button);
    Button rateButton = (Button) main.findViewById(R.id.rate_button);
    this.object = object;

    OnClickListener commentsListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            commentsVisible = !commentsVisible;
            if (commentsVisible) {
                loadComments();
            }
        }
    };
    toggle.setOnClickListener(commentsListener);
    toggleButton.setOnClickListener(commentsListener);

    RatingBar rating = (RatingBar) main.findViewById(R.id.rating);
    rating.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                ratingDialog();
            }
            return true;
        }
    });
    rateButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ratingDialog();
        }
    });

    updateRating();
}

From source file:de.damdi.fitness.activity.start_training.TrainingEntryListAdapter.java

public View getView(final int position, View convertView, ViewGroup parent) {
    View vi = convertView;/*from  www .j  a v a2 s.  c o m*/

    // last element is an empty row
    if (position == getCount() - 1) {
        vi = mInflater.inflate(R.layout.list_row_empty, null);

        // add listener
        vi.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                showDialog(null, -1);
            }
        });

        return vi;
    }

    vi = mInflater.inflate(R.layout.list_row, null);
    final FSet set = (FSet) getItem(position);

    // set values
    TextView textview_weight = (TextView) vi.findViewById(R.id.textview_weight);
    TextView textview_rep = (TextView) vi.findViewById(R.id.textview_rep);
    TextView textview_duration = (TextView) vi.findViewById(R.id.textview_duration);

    for (SetParameter para : set.getSetParameters()) {
        if (para instanceof SetParameter.Weight) {
            textview_weight.setText(para.toString());
        }
        if (para instanceof SetParameter.Duration) {
            textview_duration.setText(para.toString());
        }
        if (para instanceof SetParameter.Repetition) {
            textview_rep.setText(para.toString());
        }
    }

    // set button icons
    final ImageButton imagebutton_check = (ImageButton) vi.findViewById(R.id.imagebutton_check);
    if (mTrainingEntry.hasBeenDone(set)) {
        imagebutton_check.setImageResource(R.drawable.icon_check_green);
    } else {
        imagebutton_check.setImageResource(R.drawable.icon_check_white);
    }

    // add button listener

    imagebutton_check.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            // ignore event is TrainingEntry already has been checked
            if (mTrainingEntry.hasBeenDone(set)) {
                return;
            }

            imagebutton_check.setImageResource(R.drawable.icon_check_green);
            mTrainingEntry.setHasBeenDone(set, true);
            trainingEntryEdited();

            if (mFEx.isTrainingEntryFinished(mTrainingEntry)) {
                // start recovery timer
                RecoveryTimerManager.INSTANCE.startExerciseRecoveryTimer(mActivity);
                showExerciseFinishedDialog();
            } else {
                // start recovery timer
                RecoveryTimerManager.INSTANCE.startSetRecoveryTimer(mActivity);
            }
        }
    });

    // add lister for changing values
    final ImageView imageview_weight = (ImageView) vi.findViewById(R.id.imageview_weight);
    final ImageView imageview_rep = (ImageView) vi.findViewById(R.id.imageview_rep);
    final ImageView imageview_duration = (ImageView) vi.findViewById(R.id.imageview_duration);

    OnClickListener changeSetValuesListener = new OnClickListener() {
        @Override
        public void onClick(View view) {
            showDialog(set, position);
        }
    };
    imageview_weight.setOnClickListener(changeSetValuesListener);
    imageview_rep.setOnClickListener(changeSetValuesListener);
    imageview_duration.setOnClickListener(changeSetValuesListener);

    return vi;
}

From source file:com.android.mms.rcs.FavoriteDetailAdapter.java

@Override
public Object instantiateItem(ViewGroup view, int position) {
    mCursor.moveToPosition(position);/*w ww.  ja v a 2  s . co m*/
    View content = mInflater.inflate(R.layout.message_detail_content, view, false);

    TextView bodyText = (TextView) content.findViewById(R.id.textViewBody);
    LinearLayout mLinearLayout = (LinearLayout) content.findViewById(R.id.other_type_layout);

    mMsgType = mCursor.getInt(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.MSG_TYPE));
    if (mMsgType == RcsUtils.RCS_MSG_TYPE_TEXT) {
        initTextMsgView(bodyText);
    } else {
        bodyText.setVisibility(View.GONE);
        mLinearLayout.setVisibility(View.VISIBLE);
        ImageView imageView = (ImageView) mLinearLayout.findViewById(R.id.image_view);
        TextView textView = (TextView) mLinearLayout.findViewById(R.id.type_text_view);
        if (mMsgType != RcsUtils.RCS_MSG_TYPE_CAIYUNFILE) {
            imageView.setOnClickListener(mOnClickListener);
        }
        if (mMsgType == RcsUtils.RCS_MSG_TYPE_IMAGE) {
            initImageMsgView(mLinearLayout);
            showContentFileSize(textView);
            mContentType = "image/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_AUDIO) {
            imageView.setImageResource(R.drawable.rcs_voice);
            showContentFileSize(textView);
            mContentType = "audio/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VIDEO) {
            String thumbPath = mCursor.getString(
                    mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.THUMBNAIL));
            Bitmap bitmap = BitmapFactory.decodeFile(thumbPath);
            imageView.setImageBitmap(bitmap);
            showContentFileSize(textView);
            mContentType = "video/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_MAP) {
            imageView.setImageResource(R.drawable.rcs_map);
            String body = mCursor
                    .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.CONTENT));
            textView.setText(body);
            mContentType = "map/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VCARD) {
            textView.setVisibility(View.GONE);
            initVcardMagView(mLinearLayout);
            mContentType = "text/x-vCard";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_PAID_EMO) {
            String messageBody = mCursor
                    .getString(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.FILE_NAME));
            String[] body = messageBody.split(",");
            RcsEmojiStoreUtil.getInstance().loadImageAsynById(imageView, body[0],
                    RcsEmojiStoreUtil.EMO_STATIC_FILE);
        } else {
            bodyText.setVisibility(View.VISIBLE);
            mLinearLayout.setVisibility(View.GONE);
            initTextMsgView(bodyText);
        }
    }

    TextView detailsText = (TextView) content.findViewById(R.id.textViewDetails);
    detailsText.setText(getTextMessageDetails(mContext, mCursor, true));
    view.addView(content);

    return content;
}