Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 布局充气器未检测到xml布局_Android - Fatal编程技术网

Android 布局充气器未检测到xml布局

Android 布局充气器未检测到xml布局,android,Android,我有一个listview,我正在根据主题更改listview的行,但是布局充气器没有检测到布局,请告诉我我做错了什么。我已经清理了项目,关闭并重新打开了eclipse,但同样的问题仍然存在。请引导我 LayoutInflater inflater = getLayoutInflater(); View row = null; if(theme.equals("blue")){

我有一个listview,我正在根据主题更改listview的行,但是布局充气器没有检测到布局,请告诉我我做错了什么。我已经清理了项目,关闭并重新打开了eclipse,但同样的问题仍然存在。请引导我

  LayoutInflater inflater   = getLayoutInflater();
                View row = null;                        
                if(theme.equals("blue")){
                    row = inflater.inflate(R.layout.bluerow, parent, false);                    
                }else if (theme.equals("green")){
                //  row = inflater.inflate(R.layout.bluerow, parent, false);                    

                }else if (theme.equals("orange")){

                }else if (theme.equals("purple")){

                }else if (theme.equals("red")){

                }else if (theme.equals("pink")){

                }
例如,bluerow.xml位于布局中但未被检测到,类似地,orangerow.xml和row on位于布局文件夹中但未被检测到

使用此代码

LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.row, parent, false);
试试这个

LayoutInflater mInflater = LayoutInflater.from(context);

public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.example, null);
            holder = new ViewHolder();
            holder.txt1= (TextView) convertView
                    .findViewById(R.id.txt1);
            holder.txt2 = (TextView) convertView
                    .findViewById(R.id.txt2);


            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();

        }
              }

class ViewHolder {
        TextView txt1, txt2;
        int ref;

    }

使用下面的代码膨胀布局,然后您可以将该视图用于任何目的。这将为您提供xml文件的最大父级布局。相应地键入cast并使用

View headerView = View.inflate(this, R.layout.layout_name, null);
就像我想在相对布局中转换上面的视图一样

RelativeLayout rl_layout = (RelativeLayout) headerView;
希望它能帮助你


还有一件事需要清理并重新构建您的项目。

不检测意味着您得到了编译时错误。它不是编译错误,而是r.layout。未检测布局。我处理了布局并用不同的名称重命名了它。有没有其他方法可以重新生成R文件