我正在努力让我的ArrayAdapter工作 - 之前一直使用自定义ArrayAdapter没有问题,但这次我不确定发生了什么。
我正在尝试使用适配器创建ListView,该适配器将显示每个WeekViewEvent对象的两个字符串(mName,mLocation):
public class WeekViewEvent implements Serializable{
private long mId;
private Calendar mStartTime;
private Calendar mEndTime;
private String mName;
private String mLocation;
private int mColor;
private boolean mAllDay;
private Shader mShader;
//construcotrs, setters, getters
ArrayAdapter:
public class TEventAdapter extends ArrayAdapter<Testowa> {
public TEventAdapter (Context context, ArrayList<Testowa> testowyeventarray){
super(context, 0, testowyeventarray);}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View pojedynczyItemView = convertView;
if(pojedynczyItemView==null){
pojedynczyItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false);
}
WeekViewEvent wvevent = getItem(position);
TextView tv1 = (TextView) pojedynczyItemView.findViewById(R.id.tv_lv1);
tv1.setText(wvevent.getName());
TextView tv2 = (TextView) pojedynczyItemView.findViewById(R.id.tv_lv2);
tv2.setText(wvevent.getLocation());
return pojedynczyItemView;
}
}
但AndroidStudio突出显示我将对象位置WeekViewEvent wvevent = getItem(position);
视为不兼容类型的部分(下图):
我卡住了:/你有什么想法我的代码有什么问题吗? 谢谢你提前!
答案 0 :(得分:2)
这应该有效
将Testowa
更改为 - &gt; Testowa
public TEventAdapter(Context context,ArrayList&lt; public class TEventAdapter extends ArrayAdapter<WeekViewEvent> {
public TEventAdapter (Context context, ArrayList<WeekViewEvent> weekVieweEvent){
super(context, 0, weekVieweEvent);}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View pojedynczyItemView = convertView;
if(pojedynczyItemView==null){
pojedynczyItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false);
}
WeekViewEvent wvevent = getItem(position);
TextView tv1 = (TextView) pojedynczyItemView.findViewById(R.id.tv_lv1);
tv1.setText(wvevent.getName());
TextView tv2 = (TextView) pojedynczyItemView.findViewById(R.id.tv_lv2);
tv2.setText(wvevent.getLocation());
return pojedynczyItemView;
}
}
&gt; testowyeventarray)
公共类TEventAdapter扩展了ArrayAdapter&lt; git push -u origin master
error: src refspec master does not match any.
&gt;
$(".classname").bind("change paste keyup", function() {
if ($("#fname").val() && $("#yourMessage").val()) {
$( "#Send" ).prop( "disabled", false );
} else {
$( "#Send" ).prop( "disabled", true );
}
});