首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何解决Android中输入转换错误?

如何解决Android中输入转换错误?
EN

Stack Overflow用户
提问于 2018-06-13 10:00:27
回答 1查看 0关注 0票数 0

代码:

代码语言:javascript
复制
    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 );
EN

回答 1

Stack Overflow用户

发布于 2018-06-13 19:01:19

代码:

代码语言:javascript
复制
Double.parseDouble(currentNewsFeed.getSectionId())

如果没有帮助,请确保你的字符串不是格式错误:

代码语言:javascript
复制
Log.d("Check my string: " + currentNewsFeed.getSectionId());
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100004896

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档