代码:
View listItemView = convertView;
if (listItemView == null) {
listItemView = LayoutInflater.from( getContext() ).inflate(
R.layout.newsfeed_list_item, parent, false );
}
// Find the news at the given position in the list of news.
NewsFeed currentNewsFeed = getItem( position );
// Find the TextView with view ID.
TextView sectionIdView = (TextView) listItemView.findViewById( R.id.sectionId );
// Set the proper background color on the news circle.
// Fetch the background from the TextView, which is a GradientDrawable.
GradientDrawable sectionIdCircle = (GradientDrawable) sectionIdView.getBackground();
// Get the appropriate background color based on the current news feed
int sectionIdColor = getSectionIdColor(currentNewsFeed.getSectionId());
// Set the color on the news circle
sectionIdCircle.setColor( sectionIdColor );
发布于 2018-06-13 19:01:19
代码:
Double.parseDouble(currentNewsFeed.getSectionId())
如果没有帮助,请确保你的字符串不是格式错误:
Log.d("Check my string: " + currentNewsFeed.getSectionId());
https://stackoverflow.com/questions/-100004896
复制相似问题