0
我得到這個錯誤:陣列適配器構造不適用
Error:(31, 9) error: no suitable constructor found for ArrayAdapter(Activity,int,List<UserTreeData>)
constructor ArrayAdapter.ArrayAdapter(Context,int,int) is not applicable
(argument mismatch; List<UserTreeData> cannot be converted to int)
constructor ArrayAdapter.ArrayAdapter(Context,int,UserTreeInputData[]) is not applicable
(argument mismatch; List<UserTreeData> cannot be converted to UserTreeInputData[])
constructor ArrayAdapter.ArrayAdapter(Context,int,List<UserTreeInputData>) is not applicable
(argument mismatch; List<UserTreeData> cannot be converted to List<UserTreeInputData>)
這是我的課
package com.example.pradnyanand.thetree;
import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;
import static com.example.pradnyanand.thetree.R.layout.list_layout;
public class TreeWeekDataList extends ArrayAdapter<UserTreeInputData> {
private Activity context;
private List<UserTreeData> treeDatasList;
public TreeWeekDataList(Activity context, List<UserTreeData> treeDatasList) {
super(context, R.layout.list_layout, treeDatasList);
this.context = context;
this.treeDatasList = treeDatasList;
}
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(list_layout, null, true);
TextView dateOfPlantation = (TextView) listViewItem.findViewById(R.id.displayPlanatationDate);
TextView placeOfPlantation = (TextView) listViewItem.findViewById(R.id.displayPlantationPlace);
TextView typeOfTree = (TextView) listViewItem.findViewById(R.id.displayTreeType);
UserTreeData trees = treeDatasList.get(position);
dateOfPlantation.setText(trees.getDateOfPlanation());
placeOfPlantation.setText(trees.getPlaceOfPlanation());
typeOfTree.setText(trees.getTypeOfTree());
return listViewItem;
}
}