android – ArrayAdapter显示错误无法解决构造函数适配器错误

我的ArrayAdapter显示无法解析适配器.请让我知道语法有什么问题.

 @Override
    public void onRequestSuccess(List<Order> Items) {
        Toast.makeText(HomeActivity.this, "Success", Toast.LENGTH_SHORT).show();
         List<Order> list = new ArrayList<Order>();

        ListView listView = (ListView) findViewById(R.id.listview);

        listadapter<Order> adapter = new listadapter<String>(this, android.R.layout.simple_list_item_1, list);
        listView.setAdapter(adapter);

    }                 

MY Order类看起来像这样.

public class Order {
public String createdOn;
public String id;
public String lastModifiedOn;
public String trackingNumber;
public String tripId;
public OrderEntry orderEntry;
public String tripOrderStatusValue;
public String notificationStatus;
public String remark;
public String createdBy;
public String orderId;
public String deliveryReasonCode;
public Boolean isTripStarted;
public Boolean isTripCompleted;
public Boolean isOutScanned;
public String shipmentType;
public String deliveryTime;

}

我的listadapter看起来像这样.

公共类listadapter扩展ArrayAdapter {

public listadapter(Context context, int textViewResourceId) {
    super(context, textViewResourceId);
    // Todo Auto-generated constructor stub
}

private List<Order> items;

public listadapter(Context context, int resource, List<Order> items) {

    super(context, resource, items);

    this.items = items;

}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View v = convertView;

    if (v == null) {

        LayoutInflater vi;
        vi = LayoutInflater.from(getContext());
        v = vi.inflate(R.layout.list_row_myschedule, null);

    }

    Order p = items.get(position);

    if (p != null) {

        TextView tt = (TextView) v.findViewById(R.id.textview1);
        TextView tt1 = (TextView) v.findViewById(R.id.textview2);
        TextView tt3 = (TextView) v.findViewById(R.id.textview3);

        if (tt != null) {
            tt.setText(p.orderStatusValue);
        }
        if (tt1 != null) {

            tt1.setText(p.reasonCode);
        }
        if (tt3 != null) {

            tt3.setText(p.trackingNumber);
        }
    }

    return v;
}

}

解决方法:

泛型必须在声明/初始化中保持一致

更改

ArrayAdapter<Order> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);

ArrayAdapter<Order> adapter = new ArrayAdapter<Order>(this, android.R.layout.simple_list_item_1, list);

此外,您还要确保这是指活动上下文

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...