내 범주 목록에 대한 사용자 지정 어댑터를 만들려고합니다. 어떤 이유로 인해 inflate하려고 할 때 category_item 레이아웃에 액세스 할 수 없습니다. - R.layout.category_item이 resource
내가 내 category_item.xml 레이아웃에 액세스 할 수 있어야합니다 말한다내 ArrayAdapter에서 R.layout.mylayoutname에 액세스 할 수 없습니다.
public class CategoryAdapter extends ArrayAdapter<Category> {
LayoutInflater mInflater;
List<Category> list;
public CategoryAdapter(Context context, int resource, int textViewResourceId, List<Category> objects) {
super(context, resource, textViewResourceId, objects);
mInflater = LayoutInflater.from(context);
list = objects;
}
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if(convertView==null){
convertView=mInflater.inflate(***resource***, null);
holder = new ViewHolder();
}
return convertView;
}
// Declaring new class ViewHolder
class ViewHolder{
TextView category_name;
}
: 여기에 내 코드입니다. 그러나 어떤 이유로 목록에 표시되지 않지만 액세스 할 수는 없습니다. 사실 나는 목록에서 내 레이아웃을 보지 못합니다.
왜 그런 일이 발생하며 어떻게 해결 될 수 있습니까?
Activity 클래스에서 adapter를 호출 할 때 R.java가 가져온 –
add here 행이 올바른지 확인하십시오. – Sajmon
@StefandeBruijn 네, 명백하게 저는 잘못된 R 클래스를 가져 왔습니다. 어떻게 된 일인지 모르세요 ... 고마워요! 당신이 처음으로 내 질문에 대답 했으므로 대답으로 게시하여 받아 들일 수 있습니까? 다시 한번 고마워요! – Igal