- 53
- 0
想给一个网络音乐播放器加上一个功能,就是用户听完了一首歌以后,歌曲的标题会自动由黑色变成灰色,请问该如何实现?
原始代码如下:
static View setupListView(Activity activity, View convertView, ViewGroup parent,
MediaBrowserCompat.MediaItem item) {
if (sColorStateNotPlaying == null || sColorStatePlaying == null) {
initializeColorStateLists(activity);
}
MediaItemViewHolder holder;
Integer cachedState = STATE_INVALID;
if (convertView == null) {
convertView = LayoutInflater.from(activity)
.inflate(R.layout.media_list_item, parent, false);
holder = new MediaItemViewHolder();
holder.mImageView = (ImageView) convertView.findViewById(R.id.play_eq);
holder.mTitleView = (TextView) convertView.findViewById(R.id.title);
holder.mDescriptionView = (TextView) convertView.findViewById(R.id.description);
convertView.setTag(holder);
} else {
holder = (MediaItemViewHolder) convertView.getTag();
cachedState = (Integer) convertView.getTag(R.id.tag_mediaitem_state_cache);
}
MediaDescriptionCompat description = item.getDescription();
holder.mTitleView.setText(description.getTitle());
holder.mDescriptionView.setText(description.getSubtitle());
// If the state of convertView is different, we need to adapt the view to the
// new state.
int state = getMediaItemState(activity, item);
if (cachedState == null || cachedState != state) {
Drawable drawable = getDrawableByState(activity, state);
if (drawable != null) {
holder.mImageView.setImageDrawable(drawable);
holder.mImageView.setVisibility(View.VISIBLE);
} else {
holder.mImageView.setVisibility(View.GONE);
}
convertView.setTag(R.id.tag_mediaitem_state_cache, state);
}
return convertView;
} 0
打赏
收藏
点击回答
网站公告
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部

