когда я пытаюсь ниже строки кодаНесовместимые типы найдено java.lang: ArrayAdapter
ItemRow itemdata = data.get(position);
в классе ItemAdapter я получил ошибку
Несовместимые типы требуется: com.fragment.ItemRow найдено: java.lang .Object
полный класс ItemRow.java, как показано ниже:
Package com.fragments;
import android.graphics.drawable.Drawable;
public class ItemRow {
String itemName;
Drawable icon;
public ItemRow(String itemName, Drawable icon) {
super();
this.itemName = itemName;
this.icon = icon;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public Drawable getIcon() {
return icon;
}
public void setIcon(Drawable icon) {
this.icon = icon;
}
}
и полный класс Itemadapeter, в котором я получил несовместимый тип при попытке
-ItemRow itemdata = data.get (position); в GetView
package com.fragments;
public class ItemAdapter extends ArrayAdapter {
List data;
Context context;
int layoutResID;
public ItemAdapter(Context context, int layoutResourceId,List data) {
super(context, layoutResourceId, data);
this.data=data;
this.context=context;
this.layoutResID=layoutResourceId;
// TODO Auto-generated constructor stub
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
NewsHolder holder = null;
View row = convertView;
holder = null;
if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResID, parent, false);
holder = new NewsHolder();
holder.itemName = (TextView)row.findViewById(R.id.example_itemname);
holder.icon=(ImageView)row.findViewById(R.id.example_image);
holder.button1=(Button)row.findViewById(R.id.swipe_button1);
holder.button2=(Button)row.findViewById(R.id.swipe_button2);
holder.button3=(Button)row.findViewById(R.id.swipe_button3);
row.setTag(holder);
}
else
{
holder = (NewsHolder)row.getTag();
}
ItemRow itemdata = data.get(position);
holder.itemName.setText(itemdata.getItemName());
holder.icon.setImageDrawable(itemdata.getIcon());
holder.button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "Button 1 Clicked",Toast.LENGTH_SHORT).show();
}
});
holder.button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "Button 2 Clicked",Toast.LENGTH_SHORT).show();
}
});
holder.button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "Button 3 Clicked",Toast.LENGTH_SHORT);
}
});
return row;
}
static class NewsHolder{
TextView itemName;
ImageView icon;
Button button1;
Button button2;
Button button3;
}
}
; **Зачем?** –