Java Code Examples for android.view.View.getTag()

The following are Jave code examples for showing how to use getTag() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AndroidNetwork   File: CinemaAdapter.java   Source Code and License Vote up 8 votes
public View getView(final int position, View convertView,
		final ViewGroup parent) {
	final Holder holder;
	if (convertView == null) {
		holder = new Holder();
		convertView = context.getLayoutInflater().inflate(
				R.layout.item_cinemalist, null);
		holder.tvCinemaName = (TextView) convertView
				.findViewById(R.id.tvCinemaName);
		holder.tvCinemaId = (TextView) convertView
				.findViewById(R.id.tvCinemaId);
		convertView.setTag(holder);
	} else {
		holder = (Holder) convertView.getTag();
	}

	CinemaBean cinema = cinemaList.get(position);
	holder.tvCinemaName.setText(cinema.getCinemaName());
	holder.tvCinemaId.setText(cinema.getCinemaId());
	return convertView;
}
 
Example 2
Project: CSipSimple   File: CallLogDetailsFragment.java   Source Code and License Vote up 8 votes
@Override
public void onClick(View view) {
    String nbr = (String) view.getTag();
    if (!TextUtils.isEmpty(nbr)) {
        SipProfile acc = mAccountChooserButton.getSelectedAccount();
        Intent it = new Intent(Intent.ACTION_CALL);
        it.setData(SipUri.forgeSipUri(SipManager.PROTOCOL_CSIP, nbr));
        it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        it.putExtra(SipProfile.FIELD_ACC_ID, acc.id);
        startActivity(it);
    }
}
 
Example 3
Project: OSchina_resources_android   File: TeamDiaryDetailAdapter.java   Source Code and License Vote up 7 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = View.inflate(cxt, R.layout.list_cell_diary_detail,
                null);
        holder.week = (TextView) convertView
                .findViewById(R.id.item_diary_detail_week);
        holder.content = (TextView) convertView
                .findViewById(R.id.item_diary_detail_content);
        holder.imageWeek = (ImageView) convertView
                .findViewById(R.id.item_diary_detail_img);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    holder.week.setText(getWeek(position, holder.imageWeek));
    holder.content.setText(stripTags(datas.get(position).toString()));
    return convertView;
}
 
Example 4
Project: AutoCar   File: CardListAdapter.java   Source Code and License Vote up 7 votes
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
    View v = convertView;
    if (v == null) {
        CardAdapter cardAdapter = mCardAbles.get(position).onCreateAdapter();
        if (cardAdapter != null) {
            if (cardAdapter instanceof BaseViewModel)
                ((BaseViewModel) cardAdapter).setContext(mContext);

            v = cardAdapter.getItemView();
            if (v != null) {
                v.setTag(cardAdapter);
            }
        }
    }
    if (v != null) {
        Object tagValue = v.getTag();
        if (tagValue != null && tagValue instanceof CardAdapter) {
            CardAdapter adapter = (CardAdapter) tagValue;
            adapter.bindView(v, getItem(position));
        }
    }
    return v;
}
 
Example 5
Project: letv   File: PointItemAdapter.java   Source Code and License Vote up 7 votes
@SuppressLint({"ResourceAsColor"})
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder vh;
    if (convertView == null) {
        convertView = UIs.inflate(this.mContext, R.layout.point_item, null);
        vh = new ViewHolder(this);
        vh.title = (TextView) convertView.findViewById(R.id.point_title);
        vh.point = (TextView) convertView.findViewById(R.id.points_letv);
        vh.state = (TextView) convertView.findViewById(R.id.point_state);
        convertView.setTag(vh);
    } else {
        vh = (ViewHolder) convertView.getTag();
    }
    vh.title.setText(((PointBean) this.list.get(position)).rname);
    vh.point.setText("+" + ((PointBean) this.list.get(position)).credit);
    if (((PointBean) this.list.get(position)).state < ((PointBean) this.list.get(position)).rewardnum) {
        vh.state.setText((Integer.parseInt(((PointBean) this.list.get(position)).credit) * ((PointBean) this.list.get(position)).state) + "/" + (Integer.parseInt(((PointBean) this.list.get(position)).credit) * ((PointBean) this.list.get(position)).rewardnum));
    } else {
        vh.state.setTextColor(2131493377);
        vh.state.setText(this.mContext.getString(2131100064));
    }
    return convertView;
}
 
Example 6
Project: GitHub   File: MultiItemTypeAdapter.java   Source Code and License Vote up 7 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ItemViewDelegate itemViewDelegate = mItemViewDelegateManager.getItemViewDelegate(mDatas.get(position), position);
    int layoutId = itemViewDelegate.getItemViewLayoutId();
    ViewHolder viewHolder = null ;
    if (convertView == null)
    {
        View itemView = LayoutInflater.from(mContext).inflate(layoutId, parent,
                false);
        viewHolder = new ViewHolder(mContext, itemView, parent, position);
        viewHolder.mLayoutId = layoutId;
        onViewHolderCreated(viewHolder,viewHolder.getConvertView());
    } else
    {
        viewHolder = (ViewHolder) convertView.getTag();
        viewHolder.mPosition = position;
    }


    convert(viewHolder, getItem(position), position);
    return viewHolder.getConvertView();
}
 
Example 7
Project: Tangram-Android   File: ViewHolderCreator.java   Source Code and License Vote up 6 votes
public static ViewHolderCreator.ViewHolder getViewHolderFromView(@NonNull View view) {
    Object holder = view.getTag(R.id.TANGRAM_VIEW_HOLDER_TAG);
    if (holder instanceof ViewHolder) {
        return (ViewHolder) holder;
    }
    return null;
}
 
Example 8
Project: BookyMcBookface   File: GetBooksActivity.java   Source Code and License Vote up 6 votes
@Override
public void onClick(View v) {
    try {
        String url = (String) v.getTag();
        if (url != null) {
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    } catch (Exception e) {
        Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        Log.e("Webs", e.getMessage(), e);
    }
}
 
Example 9
Project: yyox   File: MessageAdapter.java   Source Code and License Vote up 6 votes
/**
 * 消息类型之接收的文本消息
 *
 * @param position
 * @param convertView
 * @param parent
 * @param message
 * @return
 */
private View messageWithTextReceive(int position, View convertView, ViewGroup parent, IMMessage message) {

    TextReceiveHolder holder;
    if (convertView == null) {
        convertView = inflateLayout(R.layout.kf5_message_item_with_text_left, parent);
        holder = new TextReceiveHolder(convertView);
    } else {
        holder = (TextReceiveHolder) convertView.getTag();
    }
    holder.bindData(message, position, getItem(position - 1));
    return convertView;
}
 
Example 10
Project: HeadlineNews   File: BarUtils.java   Source Code and License Vote up 6 votes
/**
 * 为view增加MarginTop为状态栏高度
 *
 * @param view view
 */
public static void addMarginTopEqualStatusBarHeight(@NonNull View view) {
    Object haveSetOffset = view.getTag(TAG_OFFSET);
    if (haveSetOffset != null && (Boolean) haveSetOffset) return;
    ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
    layoutParams.setMargins(layoutParams.leftMargin,
            layoutParams.topMargin + getStatusBarHeight(),
            layoutParams.rightMargin,
            layoutParams.bottomMargin);
    view.setTag(TAG_OFFSET, true);
}
 
Example 11
Project: aftercare-app-android   File: DCMessageFragment.java   Source Code and License Vote up 6 votes
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.btn_message_activity:

            if (listener != null && view.getTag() instanceof Routine.Type) {
                Routine.Type type = (Routine.Type) view.getTag();
                Routine routine = new Routine(type);
                listener.onStartRoutine(routine);
            }

            dismissAllowingStateLoss();
            break;
    }
}
 
Example 12
Project: logcatviewer   File: LogcatAdapter.java   Source Code and License Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View item = convertView;
    Holder holder;
    if (item == null) {
        item = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_logcat, parent, false);
        holder = new Holder(item);
    } else {
        holder = (Holder) item.getTag();
    }
    holder.parse(getItem(position));
    return item;
}
 
Example 13
Project: musicplayer   File: MyGridAdapter.java   Source Code and License Vote up 6 votes
@Override
public void onClick(View v) {
    int position=(int)v.getTag();
    Log.d("已被点击","位置:"+position);
    Toast.makeText(mContext,"点击了第"+position+"项",Toast.LENGTH_LONG).show();
    Intent intent=new Intent(mContext, RecommendInfoActivity.class);
  mContext.startActivity(intent);
}
 
Example 14
Project: GitHub   File: BoxingMediaAdapter.java   Source Code and License Vote up 6 votes
@Override
public void onClick(View v) {
    MediaItemLayout itemLayout = (MediaItemLayout) v.getTag(R.id.media_layout);
    BaseMedia media = (BaseMedia) v.getTag();
    if (mMediaConfig.getMode() == BoxingConfig.Mode.MULTI_IMG) {
        if (mOnCheckedListener != null) {
            mOnCheckedListener.onChecked(itemLayout, media);
        }
    }
}
 
Example 15
Project: android_viewtracker   File: DataProcess.java   Source Code and License Vote up 6 votes
public static void processExposureParams(HashMap<String, Object> commonInfo, View exposureView, long exposureData, HashMap<String, Object> exposureIndex) {
    try {
        HashMap<String, Object> viewData = (HashMap<String, Object>) exposureView.getTag(TrackerConstants.VIEW_TAG_PARAM);
        String viewName = TrackerUtil.getClickViewName(exposureView);
        if (TextUtils.isEmpty(viewName)) {
            TrackerLog.d("processExposureParams viewName is null");
            return;
        }

        commitExposureParams(commonInfo, viewName, viewData, exposureData, exposureIndex);
    } catch (Throwable th) {
        TrackerLog.e("processExposureParams fail," + th.getMessage());
    }
}
 
Example 16
Project: GitHub   File: TestLayoutPropertiesCase.java   Source Code and License Vote up 5 votes
public void testAlignedParentCenterCertical() {
    final View view = createContainer(container, createViewWithProperty(jsonObj0, ID0, NAME.LAYOUT_CENTERVERTICAL, ID0, TEXT0), null);
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertVerticalCenterAligned(h.container, h.v0);
}
 
Example 17
Project: Misc   File: ContactsActivity.java   Source Code and License Vote up 5 votes
@Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            // DEBUG
//            Log.d(TAG, this.getClass().getSimpleName() + ": i=" + i);
            ViewHolder viewHolder;
            // General ListView optimization code.
            if (view == null) {
                view = mInflator.inflate(R.layout.list_row_image, viewGroup,
                        false);
                viewHolder = new ViewHolder();
                viewHolder.title = (TextView) view.findViewById(R.id.title);
                viewHolder.imageView = (ImageView) view.findViewById(R.id
                        .imageview);
                view.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder) view.getTag();
            }
            String titleText;

            // Check if index is OK.
            if (i < 0 || i >= mDataArray.length) {
                titleText = "Error";
                viewHolder.title.setText(titleText);
                return view;
            }
            Data data = mDataArray[i];
            if (data == null) {
                titleText = "Error";
                viewHolder.title.setText(titleText);
                return view;
            }

            if (data.isInvalid()) {
                // Get the values for this item
                Cursor cursor = getContentResolver().query(getUri(),
                        mDesiredColumns,
                        COL_ID + "=" + mDataArray[i].getId(), null, mSortOrder
                                .sqlCommand);
                if (cursor != null && cursor.moveToFirst()) {
                    String displayName = "Unknown";
                    if (mIndexName > -1) {
                        displayName = cursor.getString(mIndexName);
                    }
                    data.setValues(displayName);
                }
                if (cursor != null) cursor.close();
            }
            mDataArray[i] = data;

            titleText = String.format(Locale.US, "%d", data.getId()) +
                    ": " + data.getName();
            viewHolder.title.setText(titleText);

            if (viewHolder.imageView != null) {
                long contactId = MessageUtils.getContactIdFromName(
                        ContactsActivity.this, data.getName());
                Bitmap bitmap = MessageUtils.loadContactPhoto(
                        getContentResolver(), contactId);
                if (bitmap == null) {
                    // DEBUG
                    // bitmap =
                    // BitmapFactory.decodeFile("/sdcard/Pictures/Art/Wildcat
                    // .jpg");
                    bitmap = BitmapFactory.decodeResource(getResources(),
                            R.drawable.android_icon);
                }
                if (bitmap != null) {
                    viewHolder.imageView.setImageBitmap(bitmap);
                } else {
                    viewHolder.imageView.setImageDrawable(null);
                }
            }

            return view;
        }
 
Example 18
Project: sealtalk-android-master   File: NewFriendListAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = mInflater.inflate(R.layout.rs_ada_user_ship, parent, false);
        holder.mName = (TextView) convertView.findViewById(R.id.ship_name);
        holder.mMessage = (TextView) convertView.findViewById(R.id.ship_message);
        holder.mHead = (SelectableRoundedImageView) convertView.findViewById(R.id.new_header);
        holder.mState = (TextView) convertView.findViewById(R.id.ship_state);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    final UserRelationshipResponse.ResultEntity bean = (UserRelationshipResponse.ResultEntity) dataSet.get(position);
    holder.mName.setText(bean.getUser().getNickname());
    String portraitUri = null;
    if (bean != null && bean.getUser() != null) {
        UserRelationshipResponse.ResultEntity.UserEntity userEntity = bean.getUser();
        portraitUri = SealUserInfoManager.getInstance().getPortraitUri(new UserInfo(
                          userEntity.getId(), userEntity.getNickname(), Uri.parse(userEntity.getPortraitUri())));
    }
    ImageLoader.getInstance().displayImage(portraitUri, holder.mHead, App.getOptions());
    holder.mMessage.setText(bean.getMessage());
    holder.mState.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mOnItemButtonClick != null) {
                mOnItemButtonClick.onButtonClick(position, v, bean.getStatus());
            }
        }
    });

    switch (bean.getStatus()) {
        case 11: //收到了好友邀请
            holder.mState.setText(R.string.agree);
            holder.mState.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.de_add_friend_selector));
            break;
        case 10: // 发出了好友邀请
            holder.mState.setText(R.string.request);
            holder.mState.setBackgroundDrawable(null);
            break;
        case 21: // 忽略好友邀请
            holder.mState.setText(R.string.ignore);
            holder.mState.setBackgroundDrawable(null);
            break;
        case 20: // 已是好友
            holder.mState.setText(R.string.added);
            holder.mState.setBackgroundDrawable(null);
            break;
        case 30: // 删除了好友关系
            holder.mState.setText(R.string.deleted);
            holder.mState.setBackgroundDrawable(null);
            break;
    }
    return convertView;
}
 
Example 19
Project: QuranAndroid   File: TranslationAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    TranslationBook translationBook = getItem(position);
    ViewHolder viewHolder ;

    if(convertView == null)
    {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.row_translate , null , true) ;
        viewHolder = new ViewHolder(convertView);
        convertView.setTag(viewHolder);

    }else{
        viewHolder = (ViewHolder) convertView.getTag();
    }

    //switch between views
    if(translationBook.bookID == -1)
    {
        viewHolder.title.setText(translationBook.bookName);
        viewHolder.split.setVisibility(View.VISIBLE);
        viewHolder.normal.setVisibility(View.GONE);

    }else{

        viewHolder.split.setVisibility(View.GONE);
        viewHolder.normal.setVisibility(View.VISIBLE);
        if(Locale.getDefault().getDisplayLanguage().equals("العربية"))
        {
            viewHolder.translationName.setText(translationBook.bookName) ;
            viewHolder.translationInfo.setText(translationBook.info);
        }else{
            viewHolder.translationName.setText(translationBook.type == 1 ? translationBook.info : translationBook.bookName) ;
            viewHolder.translationInfo.setText(translationBook.type == 1 ? translationBook.bookName : translationBook.info );
        }

        viewHolder.transaltionStatus.setImageResource(translationBook.isDownloaded == true
                ? R.drawable.ic_close : R.drawable.ic_download);

        if(translationBook.downloading == true)
        {
            viewHolder.transaltionStatus.setVisibility(View.GONE);
            viewHolder.downloading.setVisibility(View.VISIBLE);
        }else{
            viewHolder.transaltionStatus.setVisibility(View.VISIBLE);
            viewHolder.downloading.setVisibility(View.GONE);
        }

    }


    return convertView;
}
 
Example 20
Project: markor   File: FilesystemDialogAdapter.java   Source Code and License Vote up 5 votes
@Override
@SuppressWarnings("UnnecessaryReturnStatement")
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.ui__filesystem_item__root: {
            // A own item was clicked
            TagContainer data = (TagContainer) view.getTag();
            if (areItemsSelected()) {
                // There are 1 or more items selected yet
                if (!toggleSelection(data) && data.file.isDirectory()) {
                    loadFolder(data.file);
                }
            } else {
                // No pre-selection
                if (data.file.isDirectory()) {
                    loadFolder(data.file);
                } else {
                    _dopt.listener.onFsSelected(_dopt.requestId, data.file);
                }
            }
            return;
        }
        case R.id.ui__filesystem_dialog__dir_up: {
            _currentSelection.clear();
            File parent = _currentFolder.getParentFile();
            if (parent != null && parent.getAbsolutePath().startsWith(_dopt.rootFolder.getAbsolutePath())) {
                loadFolder(parent);
            }
            return;
        }
        case R.id.ui__filesystem_dialog__home: {
            _currentSelection.clear();
            loadFolder(_dopt.rootFolder);
            return;
        }
        case R.id.ui__filesystem_dialog__button_ok: {
            if (_dopt.doSelectMultiple && areItemsSelected()) {
                _dopt.listener.onFsMultiSelected(_dopt.requestId,
                        _currentSelection.toArray(new File[_currentSelection.size()]));
            } else if (_dopt.doSelectFolder && _currentFolder.exists()) {
                _dopt.listener.onFsSelected(_dopt.requestId, _currentFolder);
            }
            return;
        }
    }
}