说list_element cannot be resolved or is not a field.我在layout文件夹下已经写了list_element.xml布局文件了,而且R类里也有list_element这个静态常量了,可他就是取不到。
我发现,我把这个类写成某个Activity的内部类的时候,就可以取到了,这是为什么呢?我看其他人的源码都是可以写在其他类里的。
...全文
2788打赏收藏
LayoutInflater调用inflate时取不到值
我在另一个包下写了个BaseAdapter的子类,在getView方法中调用inflate方法,layout的值取不到 @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView==null){ convertView=inflater.inflate(R.layout.list_element, null); } } 说list_element cannot b
我也遇到这个问题了,我是在自定义组件时遇到的,我写了一个类继承了linearlayout这个类,然后再类里LayoutInflater.from(context).inflate(R.layout.customcomponent, null)时,提示我customcomponent cannot be resolved or is not a field,同求解