List of usage examples for android.view View getTag
@ViewDebug.ExportedProperty
public Object getTag()
From source file:com.roger.lineselectionwebview.LSWebView.java
/** * ?//from w w w.j ava 2 s.c o m */ private void drawImage() { int size = rectList.size(); Rect endRect = rectList.get(size - 1); Rect realEndRect = endRect; // ?left???,,? if (size > 2) { Rect endPreRect = rectList.get(size - 2); if (endRect.left == endPreRect.left) { if (endRect.width() > endPreRect.width()) { realEndRect = endPreRect; } else { realEndRect = endRect; } } } Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.del); ImageView imageView = new ImageView(mContext); imageView.setImageBitmap(bitmap); imageView.setScaleType(ScaleType.CENTER); imageView.setTag(selectContext); MyAbsoluteLayout.LayoutParams lp = new MyAbsoluteLayout.LayoutParams( MyAbsoluteLayout.LayoutParams.WRAP_CONTENT, MyAbsoluteLayout.LayoutParams.WRAP_CONTENT, realEndRect.right, realEndRect.bottom); imageView.setLayoutParams(lp); imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String tag = (String) v.getTag(); lineView.remove(tag); myLayout.removeView(v); if (onTextSelectListener != null) { onTextSelectListener.cancle(tag.split(SELECT_SPLIT)[0]); } } }); myLayout.addView(imageView, lp); }
From source file:com.aniruddhc.acemusic.player.MusicLibraryEditorActivity.MusicLibraryEditorAlbumsMultiselectAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final Cursor c = (Cursor) getItem(position); SongsListViewHolder holder = null;//w ww. jav a2 s . c om if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_albums_layout, parent, false); holder = new SongsListViewHolder(); holder.image = (ImageView) convertView.findViewById(R.id.albumThumbnailMusicLibraryEditor); holder.title = (TextView) convertView.findViewById(R.id.albumNameMusicLibraryEditor); holder.checkBox = (CheckBox) convertView.findViewById(R.id.albumCheckboxMusicLibraryEditor); holder.subText = (TextView) convertView.findViewById(R.id.albumArtistNameMusicLibraryEditor); convertView.setTag(holder); } else { holder = (SongsListViewHolder) convertView.getTag(); } final View finalConvertView = convertView; final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID)); final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST)); final String songAlbum = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM)); final String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH)); //Set the album's name and artist as the row's tag. convertView.setTag(R.string.album, songAlbum); convertView.setTag(R.string.artist, songArtist); holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); holder.subText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); holder.subText .setPaintFlags(holder.subText.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); //Set the song title. holder.title.setText(songAlbum); holder.subText.setText(songArtist); mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image, MusicLibraryEditorActivity.displayImageOptions); //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status. if (MusicLibraryEditorActivity.songDBIdsList.contains(songId)) { holder.checkBox.setChecked(true); convertView.setBackgroundColor(0xCC0099CC); } else { convertView.setBackgroundColor(0x00000000); holder.checkBox.setChecked(false); } holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) { if (isChecked == true) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0xCC0099CC); AsyncGetAlbumSongIds task = new AsyncGetAlbumSongIds(songAlbum, songArtist); task.execute(new String[] { "ADD" }); } } else if (isChecked == false) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0x00000000); AsyncGetAlbumSongIds task = new AsyncGetAlbumSongIds(songAlbum, songArtist); task.execute(new String[] { "REMOVE" }); } } } }); return convertView; }
From source file:com.aniruddhc.acemusic.player.PlaylistEditorActivity.PlaylistEditorAlbumsMultiselectAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final Cursor c = (Cursor) getItem(position); SongsListViewHolder holder = null;/*w ww .j a v a 2s . c o m*/ if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_albums_layout, parent, false); holder = new SongsListViewHolder(); holder.image = (ImageView) convertView.findViewById(R.id.albumThumbnailMusicLibraryEditor); holder.title = (TextView) convertView.findViewById(R.id.albumNameMusicLibraryEditor); holder.checkBox = (CheckBox) convertView.findViewById(R.id.albumCheckboxMusicLibraryEditor); holder.subText = (TextView) convertView.findViewById(R.id.albumArtistNameMusicLibraryEditor); convertView.setTag(holder); } else { holder = (SongsListViewHolder) convertView.getTag(); } final View finalConvertView = convertView; final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID)); final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST)); final String songAlbum = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM)); final String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH)); //Set the album's name and artist as the row's tag. convertView.setTag(R.string.album, songAlbum); convertView.setTag(R.string.artist, songArtist); holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); holder.subText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); holder.subText .setPaintFlags(holder.subText.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); //Set the song title. holder.title.setText(songAlbum); holder.subText.setText(songArtist); mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image, PlaylistEditorActivity.displayImageOptions); //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status. if (PlaylistEditorActivity.songDBIdsList.contains(songId)) { holder.checkBox.setChecked(true); convertView.setBackgroundColor(0xCC0099CC); } else { convertView.setBackgroundColor(0x00000000); holder.checkBox.setChecked(false); } holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) { if (isChecked == true) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0xCC0099CC); AsyncGetAlbumSongIds task = new AsyncGetAlbumSongIds(mContext, songAlbum, songArtist); task.execute(new String[] { "ADD" }); } } else if (isChecked == false) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0x00000000); AsyncGetAlbumSongIds task = new AsyncGetAlbumSongIds(mContext, songAlbum, songArtist); task.execute(new String[] { "REMOVE" }); } } } }); return convertView; }
From source file:com.battlelancer.seriesguide.adapters.SearchResultsAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (!mDataValid) { throw new IllegalStateException("this should only be called when the cursor is valid"); }// w w w. ja v a 2s .co m if (!mCursor.moveToPosition(position)) { throw new IllegalStateException("couldn't move cursor to position " + position); } final ViewHolder viewHolder; if (convertView == null) { convertView = newView(mContext, mCursor, parent); viewHolder = new ViewHolder(); viewHolder.showTitle = (TextView) convertView.findViewById(R.id.textViewShowTitle); viewHolder.episodeTitle = (TextView) convertView.findViewById(R.id.textViewEpisodeTitle); viewHolder.searchSnippet = (TextView) convertView.findViewById(R.id.textViewSearchSnippet); viewHolder.watchedStatus = (ImageView) convertView.findViewById(R.id.imageViewWatchedStatus); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.showTitle.setText(mCursor.getString(SearchQuery.SHOW_TITLE)); viewHolder.watchedStatus.setImageResource(EpisodeTools.isWatched(mCursor.getInt(SearchQuery.WATCHED)) ? Utils.resolveAttributeToResourceId(mContext.getTheme(), R.attr.drawableWatched) : Utils.resolveAttributeToResourceId(mContext.getTheme(), R.attr.drawableWatch)); // ensure matched term is bold viewHolder.searchSnippet.setText(Html.fromHtml(mCursor.getString(SearchQuery.OVERVIEW))); // episode int number = mCursor.getInt(SearchQuery.NUMBER); int season = mCursor.getInt(SearchQuery.SEASON); String title = mCursor.getString(SearchQuery.TITLE); viewHolder.episodeTitle.setText(Utils.getNextEpisodeString(mContext, season, number, title)); return convertView; }
From source file:com.mb.kids_mind.Adapter.SimilarListAdapter.java
@Override public View getView(final int position, View cView, ViewGroup parent) { ViewHolder holder = null;/* w ww . jav a2 s .com*/ final SimilarItem contents = list.get(position); final SharedPreferences pref = mContext.getSharedPreferences("pref", mContext.MODE_PRIVATE); final SharedPreferences.Editor editor = pref.edit(); if (cView == null) { //cView=View.inflate(mContext, layout,null); cView = LayoutInflater.from(mContext).inflate(layout, parent, false); holder = new ViewHolder(); holder.image = (ImageView) cView.findViewById(R.id.image); cView.setTag(holder); // Log.v(TAG,"cvew==null"); } else { holder = (ViewHolder) cView.getTag(); // Log.v(TAG,"cvew!=null"); } //holder.image.setImageResource(contents.getRes()); // String DirPath = Environment.getExternalStorageDirectory() // .getAbsolutePath(); // DirPath = DirPath + "/" + "KidsMind2" + "/"; // // File cameraDir = new File(DirPath); // if (!cameraDir.exists()) { // // cameraDir.mkdirs(); // } // File f1 = new File(cameraDir, contents.advice_image); // if (f1.exists()) { // holder.image.setImageURI(Uri.fromFile(f1)); // //mLoader.DisplayImage(f1.getAbsolutePath(), holder.imageView); // // } else { // new DownTask().execute( // (Const.IMAGE_LOAD_URL+"/" + contents.advice_image).trim(),f1,holder.image); // // } requestMyImage(holder.image, contents.advice_image); return cView; }
From source file:com.aniruddhc.acemusic.player.BlacklistManagerActivity.BlacklistedAlbumsMultiselectAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final Cursor c = (Cursor) getItem(position); SongsListViewHolder holder = null;//from w w w .ja v a 2s . c o m if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_albums_layout, parent, false); holder = new SongsListViewHolder(); holder.image = (ImageView) convertView.findViewById(R.id.albumThumbnailMusicLibraryEditor); holder.title = (TextView) convertView.findViewById(R.id.albumNameMusicLibraryEditor); holder.checkBox = (CheckBox) convertView.findViewById(R.id.albumCheckboxMusicLibraryEditor); holder.subText = (TextView) convertView.findViewById(R.id.albumArtistNameMusicLibraryEditor); convertView.setTag(holder); } else { holder = (SongsListViewHolder) convertView.getTag(); } final View finalConvertView = convertView; final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID)); final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST)); final String songAlbum = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM)); final String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH)); final String songBlacklistStatus = c.getString(c.getColumnIndex(DBAccessHelper.BLACKLIST_STATUS)); //Set the album's name and artist as the row's tag. convertView.setTag(R.string.album, songAlbum); convertView.setTag(R.string.artist, songArtist); holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); holder.subText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); holder.subText .setPaintFlags(holder.subText.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); //Set the song title. holder.title.setText(songAlbum); holder.subText.setText(songArtist); mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image, BlacklistManagerActivity.displayImageOptions); //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status. if (BlacklistManagerActivity.songIdBlacklistStatusPair.get(songId).equals("TRUE")) { holder.checkBox.setChecked(true); convertView.setBackgroundColor(0xCCFF4444); } else { convertView.setBackgroundColor(0x00000000); holder.checkBox.setChecked(false); } holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) { if (isChecked == true) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0xCCFF4444); AsyncBlacklistAlbumTask task = new AsyncBlacklistAlbumTask(songAlbum, songArtist); task.execute(new String[] { "ADD" }); } } else if (isChecked == false) { //Only receive inputs by the user and ignore any system-made changes to the checkbox state. if (checkbox.isPressed()) { finalConvertView.setBackgroundColor(0x00000000); AsyncBlacklistAlbumTask task = new AsyncBlacklistAlbumTask(songAlbum, songArtist); task.execute(new String[] { "REMOVE" }); } } } }); return convertView; }
From source file:com.easemob.chatuidemo.adapter.NewFriendsMsgAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = View.inflate(context, R.layout.row_invite_msg, null); holder.avator = (ImageView) convertView.findViewById(R.id.avatar); holder.reason = (TextView) convertView.findViewById(R.id.message); holder.name = (TextView) convertView.findViewById(R.id.name); holder.status = (Button) convertView.findViewById(R.id.user_state); holder.groupContainer = (LinearLayout) convertView.findViewById(R.id.ll_group); holder.groupname = (TextView) convertView.findViewById(R.id.tv_groupName); // holder.time = (TextView) convertView.findViewById(R.id.time); convertView.setTag(holder);//from w w w .j av a 2 s. c o m } else { holder = (ViewHolder) convertView.getTag(); } String str1 = context.getResources().getString(R.string.Has_agreed_to_your_friend_request); String str2 = context.getResources().getString(R.string.agree); String str3 = context.getResources().getString(R.string.Request_to_add_you_as_a_friend); String str4 = context.getResources().getString(R.string.Apply_to_the_group_of); String str5 = context.getResources().getString(R.string.Has_agreed_to); String str6 = context.getResources().getString(R.string.Has_refused_to); final InviteMessage msg = getItem(position); if (msg != null) { if (msg.getGroupId() != null) { // ??? holder.groupContainer.setVisibility(View.VISIBLE); holder.groupname.setText(msg.getGroupName()); } else { holder.groupContainer.setVisibility(View.GONE); } holder.reason.setText(msg.getReason()); holder.name.setText(msg.getFrom()); // holder.time.setText(DateUtils.getTimestampString(new // Date(msg.getTime()))); if (msg.getStatus() == InviteMesageStatus.BEAGREED) { holder.status.setVisibility(View.INVISIBLE); holder.reason.setText(str1); } else if (msg.getStatus() == InviteMesageStatus.BEINVITEED || msg.getStatus() == InviteMesageStatus.BEAPPLYED) { holder.status.setVisibility(View.VISIBLE); holder.status.setEnabled(true); holder.status.setBackgroundResource(android.R.drawable.btn_default); holder.status.setText(str2); if (msg.getStatus() == InviteMesageStatus.BEINVITEED) { if (msg.getReason() == null) { // ? holder.reason.setText(str3); } } else { // if (TextUtils.isEmpty(msg.getReason())) { holder.reason.setText(str4 + msg.getGroupName()); } } // holder.status.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // ???? acceptInvitation(holder.status, msg); } }); } else if (msg.getStatus() == InviteMesageStatus.AGREED) { holder.status.setText(str5); holder.status.setBackgroundDrawable(null); holder.status.setEnabled(false); } else if (msg.getStatus() == InviteMesageStatus.REFUSED) { holder.status.setText(str6); holder.status.setBackgroundDrawable(null); holder.status.setEnabled(false); } // ? } return convertView; }
From source file:com.android.calculator2.EventListener.java
@Override public boolean onLongClick(View view) { switch (view.getId()) { case R.id.del: mHandler.onClear();/*www . ja va 2s .c om*/ return true; case R.id.next: // Handle back EditText active = mHandler.mDisplay.getActiveEditText(); if (active.getSelectionStart() == 0) { View v = mHandler.mDisplay.getActiveEditText().focusSearch(View.FOCUS_BACKWARD); if (v != null) v.requestFocus(); active = mHandler.mDisplay.getActiveEditText(); active.setSelection(active.getText().length()); } else { active.setSelection(active.getSelectionStart() - 1); } return true; } if (view.getTag() != null) { String text = (String) view.getTag(); if (!text.isEmpty()) { Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show(); return true; } } if (view instanceof TextView && ((TextView) view).getHint() != null) { String text = ((TextView) view).getHint().toString(); if (text.length() >= 2) { // Add paren after sin, cos, ln, etc. from buttons text += "("; } mHandler.insert(text); returnToBasic(); return true; } return false; }
From source file:com.vmihalachi.turboeditor.adapter.AdapterDetailedList.java
/** * {@inheritDoc}//from ww w . j a va 2s. com */ @Override public View getView(final int position, View convertView, final ViewGroup parent) { if (convertView == null) { convertView = this.inflater.inflate(R.layout.item_file_list, null); final ViewHolder hold = new ViewHolder(); hold.nameLabel = (TextView) convertView.findViewById(android.R.id.title); hold.sizeLabel = (TextView) convertView.findViewById(android.R.id.text1); hold.dateLabel = (TextView) convertView.findViewById(android.R.id.text2); hold.icon = (ImageView) convertView.findViewById(android.R.id.icon); convertView.setTag(hold); final FileDetail fileDetail = fileDetails.get(position); final String fileName = fileDetail.getName(); setIcon(hold, fileDetail); hold.nameLabel.setText(fileName); hold.sizeLabel.setText(fileDetail.getSize()); hold.dateLabel.setText(fileDetail.getDateModified()); } else { final ViewHolder hold = ((ViewHolder) convertView.getTag()); final FileDetail fileDetail = fileDetails.get(position); final String fileName = fileDetail.getName(); setIcon(hold, fileDetail); hold.nameLabel.setText(fileName); hold.sizeLabel.setText(fileDetail.getSize()); hold.dateLabel.setText(fileDetail.getDateModified()); } return convertView; }
From source file:net.idlesoft.android.apps.github.adapters.RepositoriesListAdapter.java
@Override public View doGetView(final int index, View convertView, final ViewGroup parent) { ViewHolder holder;//from www. ja v a2s. c o m if (convertView == null) { convertView = mInflater.inflate(R.layout.repository_list_item, null); holder = new ViewHolder(); holder.repo_name = (TextView) convertView.findViewById(R.id.repository_list_item_name); holder.repo_owner = (TextView) convertView.findViewById(R.id.repository_list_item_owner); holder.repo_owner_label = (TextView) convertView.findViewById(R.id.repository_list_item_owner_label); holder.repo_description = (TextView) convertView.findViewById(R.id.repository_list_item_description); holder.repo_fork = (TextView) convertView.findViewById(R.id.repository_list_item_fork); holder.repo_watch_count = (TextView) convertView.findViewById(R.id.repository_list_item_watch_count); holder.repo_fork_count = (TextView) convertView.findViewById(R.id.repository_list_item_fork_count); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } try { final JSONObject object = (JSONObject) getData().get(index); String owner = ""; owner = object.getString("owner"); holder.repo_name.setText(object.getString("name")); holder.repo_owner.setText(owner); holder.repo_description.setText(object.getString("description")); holder.repo_fork_count.setText(object.getString("forks")); holder.repo_watch_count.setText(object.getString("watchers")); if (object.getBoolean("fork")) { holder.repo_fork.setText("(Fork) "); } else { holder.repo_fork.setText(""); } } catch (final JSONException e) { holder.repo_owner.setVisibility(View.GONE); holder.repo_owner_label.setVisibility(View.GONE); holder.repo_description.setVisibility(View.GONE); } return convertView; }