我代码如下:
private LayoutInflater mInflater = null;
public MyAdapter(Context context,int[] _color,int[] _text)
{
    mInflater = LayoutInflater.from(context);
    color = _color;
    text = _text;
}
public View getView(int position, View convertView, ViewGroup parent) {
      //View test_view = null;
     if(convertView == null)
     {
       convertView = mInflater.inflate(R.layout.changecolor, null);//调试时就在这句报找不资源了。
       //test_view = View.inflate(context, R.layout.changecolor, null);这个是我在网上找的还以为1.5版本的是用它//可以代替上面那inflate方法可用了还是不行报一样的错误。
       veiw_Holder = new ViewHolder();
veiw_Holder.m_Text = (TextView)convertView.findViewById(R.id.my_text);
emp_view.setTag(veiw_Holder);
     }else
          veiw_Holder = (ViewHolder)convertView.getTag();
veiw_Holder.m_Text.setText(text[position]);
veiw_Holder.m_Text.setBackgroundResource(color[position]);
return convertView;
}
哪个如果知道的话就告诉我下。我用的是sdk 1.5 r2版本的。

解决方案 »

  1.   

    我后来看了下我那res/layout/changecolor.xml有这文件,可为什么还说找不到哦?
      

  2.   

    convertView = mInflater.inflate(R.layout.changecolor, null);//调试时就在这句报找不资源了。 convertView = context.mInflater.inflate(R.layout.changecolor, null);context是你构造时传进来的
      

  3.   

    Android的project里面经常会碰到这种错误,你可以试试:
    1、刷新project;
    2、删掉R.java,重新生成一个;
    3、重建project。。
      

  4.   

    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    对mInflater 赋值的时候你用这个试试
      

  5.   

    这个应该没用LayoutInflater.from(context); 方法最后也是调用的(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      

  6.   

    convertView = mInflater.inflate(R.layout.changecolor, null);
    这种写法绝对没错。我的android版本和你一样,没有问题。
    还是从资源上入手吧
      

  7.   

    首先声明:我不是为分而来的,我是为学技术而解答的!
    不知道你的问题解决了没有,我这里有一种解决方案,你可以参考一下:
    我将修改的地方用红色标记出来,你再试试看!private LayoutInflater mInflater = null; 
    public MyAdapter(Context context,int[] _color,int[] _text) 

        mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);    color = _color; 
        text = _text; 

    public View getView(int position, View convertView, ViewGroup parent) { 
        if(convertView == null) 
        { 
          convertView = (View)mInflater.inflate(R.layout.changecolor, null);//调试时就在这句报找不资源了。 
          veiw_Holder = new ViewHolder(); 
          veiw_Holder.m_Text = (TextView)convertView.findViewById(R.id.my_text); 
          emp_view.setTag(veiw_Holder); 
        }else 
              veiw_Holder = (ViewHolder)convertView.getTag(); 
        veiw_Holder.m_Text.setText(text[position]); 
        veiw_Holder.m_Text.setBackgroundResource(color[position]); 
        return convertView;