Java Code Examples for android.widget.RelativeLayout.setTag()

The following are Jave code examples for showing how to use setTag() of the android.widget.RelativeLayout 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: Divertio   File: SongFixedAdapter.java   Source Code and License Vote up 6 votes
@Override
public View getView(final int position, final View convertView, ViewGroup parentView) {
    final RelativeLayout songListLayout = (RelativeLayout) songListInflater.inflate(R.layout.list_item_song_fixed, parentView, false);
    if (position % 2 - 1 == 0) {
        songListLayout.setBackgroundResource(R.color.gray_2);
    } else {
        songListLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get the parts of a song layout
    //ImageView songItemIcon = (ImageView) songListLayout.findViewById(R.id.song_icon);
    TextView songItemName = (TextView) songListLayout.findViewById(R.id.song_name);
    TextView songItemArtist = (TextView) songListLayout.findViewById(R.id.song_composer);

    // Set the parts equal to the corresponding song
    SongData songItem = songDataList.get(position);
    //songItemIcon.setImageDrawable(songItem.getSongCover());
    songItemName.setText(songItem.getSongName());
    songItemArtist.setText(songItem.getSongArtist());

    // Set position as tag
    songListLayout.setTag(position);
    return songListLayout;
}
 
Example 2
Project: Divertio   File: MenuDrawerAdapter.java   Source Code and License Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parentView) {

    // Get the parts
    menuItemLayout = (RelativeLayout) layoutInflater.inflate(R.layout.list_item_menu_drawer, parentView, false);
    ImageView imageView = (ImageView) menuItemLayout.findViewById(R.id.menu_icon);
    TextView textView = (TextView) menuItemLayout.findViewById(R.id.menu_title);

    // Set the parts equal to the corresponding part
    Drawable icon = activity.getResources().getDrawable(iconIdList[position]);
    String title = titleList[position];
    imageView.setImageDrawable(icon);
    textView.setText(title);

    // Set position as tag
    menuItemLayout.setTag(position);
    return menuItemLayout;
}
 
Example 3
Project: FastEc   File: BaseBottomDelegate.java   Source Code and License Vote up 6 votes
@Override
public void onBindView(@Nullable Bundle savedInstanceState, View rootView) {
    final int size = ITEMS.size();
    for (int i = 0; i < size; i++) {
        LayoutInflater.from(getContext()).inflate(R.layout.bottom_item_icon_text_layout, mBottomBar);
        final RelativeLayout item = (RelativeLayout) mBottomBar.getChildAt(i);
        //设置每个item的点击事件
        item.setTag(i);
        item.setOnClickListener(this);
        final IconTextView itemIcon = (IconTextView) item.getChildAt(0);
        final AppCompatTextView itemTitle = (AppCompatTextView) item.getChildAt(1);
        final BottomTabBean bean = TAB_BEANS.get(i);
        //初始化数据
        itemIcon.setText(bean.getICON());
        itemTitle.setText(bean.getTITLE());
        if (i == mIndexDelegate) {
            itemIcon.setTextColor(mClickedColor);
            itemTitle.setTextColor(mClickedColor);
        }
    }
    final ISupportFragment[] delegateArray = ITEM_DELEGATES.toArray(new ISupportFragment[size]);
    getSupportDelegate().loadMultipleRootFragment(R.id.bottom_bar_delegate_container, mIndexDelegate, delegateArray);

}
 
Example 4
Project: tumbviewer   File: PhotoPostVH.java   Source Code and License Vote up 6 votes
private void setTrailContent() {
    List<TrailItem> trails = postsItem.getTrail();
    if (trails != null && trails.size() > 0) {
        trailLayout.removeAllViews();
        createTrailView(trails.size());
        for (int i = 0; i < trails.size(); i++) {
            RelativeLayout layout = trailViewCache.get(i);
            SimpleDraweeView avatar = (SimpleDraweeView) layout.findViewById(R.id.trail_avatar);
            TextView name = (TextView) layout.findViewById(R.id.trail_name);
            TextView content = (TextView) layout.findViewById(R.id.trail_content);
            FrescoUtils.setTumblrAvatarUri(avatar, trails.get(i).getBlog().getName(), 128);
            name.setText(trails.get(i).getBlog().getName());
            content.setText(fromHtlmCompat(trails.get(i).getContent_raw()));
            layout.setTag(trails.get(i).getBlog().getName());
            trailLayout.addView(layout);
        }
        trailLayout.setVisibility(View.VISIBLE);
    } else {
        trailLayout.setVisibility(View.GONE);
    }
}
 
Example 5
Project: boohee_v5.6   File: FragmentApn.java   Source Code and License Vote up 6 votes
private void updateSelect() {
    this.viewImages.removeAllViews();
    if (this.mPathList.size() > 0) {
        Iterator it = this.mPathList.iterator();
        while (it.hasNext()) {
            String path = (String) it.next();
            RelativeLayout view = (RelativeLayout) LayoutInflater.from(getActivity()).inflate
                    (R.layout.me, null);
            ImageView view_delete_image = (ImageView) view.findViewById(R.id.view_delete_image);
            ImageView view_image = (ImageView) view.findViewById(R.id.view_image);
            view_delete_image.setTag(path);
            view_image.setTag(path);
            view_delete_image.setOnClickListener(this.mDeleteClick);
            view.setTag(path);
            this.imageLoader.displayImage("file://" + path, view_image, ImageLoaderOptions
                    .avatar());
            float dimen = getResources().getDimension(R.dimen.ba);
            this.viewImages.addView(view, new LayoutParams((int) dimen, (int) dimen));
            this.viewImages.invalidate();
        }
    }
}
 
Example 6
Project: YCCustomText   File: HyperTextEditor.java   Source Code and License Vote up 6 votes
/**
 * 生成图片View
 */
private RelativeLayout createImageLayout() {
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.edit_image_view, null);
    layout.setTag(viewTagIndex++);
    View closeView = layout.findViewById(R.id.image_close);
    //closeView.setVisibility(GONE);
    closeView.setTag(layout.getTag());
    closeView.setOnClickListener(btnListener);
    return layout;
}
 
Example 7
Project: GitHub   File: ConsoleActivity.java   Source Code and License Vote up 5 votes
@Override
public Object instantiateItem(ViewGroup container, int position) {
	if (bound == null || bound.getBridges().size() <= position) {
		Log.w(TAG, "Activity not bound when creating TerminalView.");
	}
	TerminalBridge bridge = bound.getBridges().get(position);
	bridge.promptHelper.setHandler(promptHandler);

	// inflate each terminal view
	RelativeLayout view = (RelativeLayout) inflater.inflate(
			R.layout.item_terminal, container, false);

	// set the terminal name overlay text
	TextView terminalNameOverlay = (TextView) view.findViewById(R.id.terminal_name_overlay);
	terminalNameOverlay.setText(bridge.host.getNickname());

	// and add our terminal view control, using index to place behind overlay
	final TerminalView terminal = new TerminalView(container.getContext(), bridge, pager);
	terminal.setId(R.id.terminal_view);
	view.addView(terminal, 0);

	// Tag the view with its bridge so it can be retrieved later.
	view.setTag(bridge);

	container.addView(view);
	terminalNameOverlay.startAnimation(fade_out_delayed);
	return view;
}
 
Example 8
Project: Divertio   File: SongAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(final int position, final View convertView, ViewGroup parentView) {
    final RelativeLayout songListLayout = (RelativeLayout) songListInflater.inflate(R.layout.list_item_song, parentView, false);
    if (position % 2 - 1 == 0) {
        songListLayout.setBackgroundResource(R.color.gray_2);
    } else {
        songListLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get the parts of a song layout
    //ImageView songItemIcon = (ImageView) songListLayout.findViewById(R.id.song_icon);
    ImageView songOverflowIcon = (ImageView) songListLayout.findViewById(R.id.song_overflow);
    TextView songItemName = (TextView) songListLayout.findViewById(R.id.song_name);
    TextView songItemArtist = (TextView) songListLayout.findViewById(R.id.song_composer);

    // Set the parts equal to the corresponding song
    SongData songItem = songDataList.get(position);
    //songItemIcon.setImageDrawable(songItem.getSongCover());
    songItemName.setText(songItem.getSongName());
    songItemArtist.setText(songItem.getSongArtist());

    // Set on click listener for overflow
    songOverflowIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((MainActivity) activity).showChoiceMenu(songListLayout, position);
        }
    });

    // Set position as tag
    songListLayout.setTag(position);
    return songListLayout;
}
 
Example 9
Project: Divertio   File: PlaylistAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(final int position, View convertView, ViewGroup parentView) {
    final RelativeLayout playlistLayout = (RelativeLayout) playlistInflater.inflate(R.layout.list_item_playlist, parentView, false);
    if (position % 2 - 1 == 0) {
        playlistLayout.setBackgroundResource(R.color.gray_2);
    } else {
        playlistLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get the parts of a playlist layout
    //ImageView playlistItemIcon = (ImageView) playlistLayout.findViewById(R.id.playlist_icon);
    ImageView playlistOverflowIcon = (ImageView) playlistLayout.findViewById(R.id.playlist_overflow);
    TextView playlistItemName = (TextView) playlistLayout.findViewById(R.id.playlist_name);
    TextView playlistItemSize = (TextView) playlistLayout.findViewById(R.id.playlist_size);

    // Set the parts equal to the corresponding playlist
    PlaylistData playlistItem = playlistDataList.get(position);
    //playlistItemIcon.setImageDrawable(playlistItem.getPlaylistIcon());
    playlistItemName.setText(playlistItem.getPlaylistName());
    if (playlistItem.getNumSongs() != 1) {
        playlistItemSize.setText(Integer.toString(playlistItem.getNumSongs()) + " songs");
    } else {
        playlistItemSize.setText(Integer.toString(playlistItem.getNumSongs()) + " song");
    }

    // Set on click listener for overflow
    playlistOverflowIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((PlaylistMenuActivity) activity).showChoiceMenu(playlistLayout, position);
        }
    });

    // Set position as tag
    playlistLayout.setTag(position);
    return playlistLayout;
}
 
Example 10
Project: Divertio   File: AlbumAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(final int position, final View convertView, ViewGroup parentView) {
    relativeLayout = (RelativeLayout) layoutInflater.inflate(R.layout.list_item_album, parentView, false);
    if (position % 2 - 1 == 0) {
        relativeLayout.setBackgroundResource(R.color.gray_2);
    } else {
        relativeLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get parts of layout
    ImageView albumCover = (ImageView) relativeLayout.findViewById(R.id.album_cover);
    TextView albumName = (TextView) relativeLayout.findViewById(R.id.album_name);
    TextView albumSize = (TextView) relativeLayout.findViewById(R.id.album_size);

    // Get values
    String name = keyList.get(position);
    Drawable cover = songAlbumList.get(name).get(0).getSongCover();
    RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(activity.getResources(), ((BitmapDrawable) cover).getBitmap());
    drawable.setCornerRadius(50.0f);
    int size = songAlbumList.get(name).size();

    // Set values
    albumCover.setImageDrawable(drawable);
    albumName.setText(name);
    if (size == 1) {
        albumSize.setText("1 song");
    } else {
        albumSize.setText(Integer.toString(size) + " songs");
    }

    // Return
    relativeLayout.setTag(position);
    return relativeLayout;
}
 
Example 11
Project: Divertio   File: ArtistAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(final int position, final View convertView, ViewGroup parentView) {
    relativeLayout = (RelativeLayout) layoutInflater.inflate(R.layout.list_item_artist, parentView, false);
    if (position % 2 - 1 == 0) {
        relativeLayout.setBackgroundResource(R.color.gray_2);
    } else {
        relativeLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get parts of layout
    TextView artistName = (TextView) relativeLayout.findViewById(R.id.artist_name);
    TextView artistSize = (TextView) relativeLayout.findViewById(R.id.artist_size);

    // Get values
    String name = keyList.get(position);
    int size = songArtistList.get(name).size();

    // Set values
    artistName.setText(name);
    if (size == 1) {
        artistSize.setText("1 song");
    } else {
        artistSize.setText(Integer.toString(size) + " songs");
    }

    // Return
    relativeLayout.setTag(position);
    return relativeLayout;
}
 
Example 12
Project: Divertio   File: GenreAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(final int position, final View convertView, ViewGroup parentView) {
    relativeLayout = (RelativeLayout) layoutInflater.inflate(R.layout.list_item_genre, parentView, false);
    if (position % 2 - 1 == 0) {
        relativeLayout.setBackgroundResource(R.color.gray_2);
    } else {
        relativeLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get parts of layout
    TextView genreName = (TextView) relativeLayout.findViewById(R.id.genre_name);
    TextView genreSize = (TextView) relativeLayout.findViewById(R.id.genre_size);

    // Get values
    String name = keyList.get(position);
    int size = songGenreList.get(name).size();

    // Set values
    genreName.setText(name);
    if (size == 1) {
        genreSize.setText("1 song");
    } else {
        genreSize.setText(Integer.toString(size) + " songs");
    }

    // Return
    relativeLayout.setTag(position);
    return relativeLayout;
}
 
Example 13
Project: YCCustomText   File: HyperTextView.java   Source Code and License Vote up 5 votes
/**
 * 生成图片View
 */
private RelativeLayout createImageLayout() {
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.edit_image_view, null);
    layout.setTag(viewTagIndex++);
    View closeView = layout.findViewById(R.id.image_close);
    closeView.setVisibility(GONE);
    return layout;
}
 
Example 14
Project: RLibrary   File: T.java   Source Code and License Vote up 5 votes
private static View createToastView(Context context) {
        RelativeLayout root = new RelativeLayout(context);
        root.setTag("root");
        if (isSupport()) {
            root.setBackgroundResource(context.getResources().getIdentifier("colorAccent", "color", context.getPackageName()));
        }
        //root.setBackgroundColor(Color.RED);
        WindowManager.LayoutParams rootParams = new WindowManager.LayoutParams(-1, -2);
        rootParams.gravity = Gravity.TOP;
        root.setLayoutParams(rootParams);

        LinearLayout layout = new LinearLayout(context);
        layout.setOrientation(LinearLayout.HORIZONTAL);
        if (isSupport()) {
            layout.setBackgroundResource(context.getResources().getIdentifier("colorAccent", "color", context.getPackageName()));
        }
//        layout.setBackgroundResource(android.R.color.holo_red_dark);
//        layout.setVerticalGravity(Gravity.VERTICAL_GRAVITY_MASK);
        final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(-2, -2);
        params.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(params);
        layout.setMinimumHeight(getMinHeight(context));

        ImageView imageView = new ImageView(context);
        imageView.setTag("image");
        imageView.setVisibility(View.GONE);

        TextView textView = new TextView(context);
        textView.setTag("text");
        textView.setTextColor(Color.WHITE);

        final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
        layoutParams.setMargins(getMinHeight(context, 10), 0, 0, 0);
        layoutParams.gravity = Gravity.CENTER_VERTICAL;

        layout.addView(imageView, layoutParams);
        layout.addView(textView, layoutParams);
        root.addView(layout);
        return root;
    }