Java requestLayout() 被 android.widget.RelativeLayout 错误调用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21249935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 07:39:53  来源:igfitidea点击:

requestLayout() improperly called by android.widget.RelativeLayout android

javaandroidandroid-listviewandroid-adapterview

提问by venu

i have implemented listview customadapter when displaying listview it showing below warring how to reslove it .

我在显示 listview 时实现了 listview customadapter 它显示下面显示如何重新使用它。

requestLayout() improperly called by android.widget.RelativeLayout{b42acc20 V.E..... ......ID 0,-52-480,0 #7f0700ec app:id/ptr_id_header} during layout: running second layout pass

java code

代码

public View getView(int position, View convertView, ViewGroup parent)
{
    View view = convertView;
    if (view == null)
    {
        LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = vi.inflate(R.layout.listitemrow, null);
    }
    RssItem rssItem = mRssItemList.get(position);
    if (rssItem != null)
    {
        TextView title = (TextView) view.findViewById(R.id.rowtitle);
        if (title != null)
        {
            title.setText(rssItem.getTitle());
        }
    }
    return view;
}

回答by nonahex

Is RelativeLayout a layout, you are inflating? If it is, then try to change line

相对布局是一种布局,你在膨胀吗?如果是,则尝试换行

 view = vi.inflate(R.layout.listitemrow, null);

to this

对此

 view = vi.inflate(R.layout.listitemrow, parent, false);