我试图将一些信息从我的片段传递给我的适配器以显示 ListView,它确实通过了,但 ListView 在加载完成后没有显示任何内容。
我确信适配器类有问题。
(item
是我传递的数据的自定义类)
适配器代码:
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
public class MobileArrayAdapter extends ArrayAdapter<List<item>> {
private final Context context;
private final List<item> markers;
private final static String[] a={"s"};
public MobileArrayAdapter(Context context, List<item> markers) {
super(context, R.layout.list_item);
this.context = context;
this.markers = markers;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.list_item, parent, false);
TextView title = (TextView) rowView.findViewById(R.id.title);
ProgressBar loader = (ProgressBar) rowView.findViewById(R.id.loader);
ImageView image = (ImageView) rowView.findViewById(R.id.itemimgae);
TextView views = (TextView) rowView.findViewById(R.id.views);
TextView likes=(TextView) rowView.findViewById(R.id.likes);
TextView upvote=(TextView) rowView.findViewById(R.id.upvote);
TextView downvote=(TextView) rowView.findViewById(R.id.downvote);
TextView desc=(TextView) rowView.findViewById(R.id.desc);
TextView pub =(TextView) rowView.findViewById(R.id.pub);
TextView idnum =(TextView) rowView.findViewById(R.id.idnum);
//Log.e("title",items.get(1).get(0));
title.setText(" "+markers.get(position).getTitle());
// views.setText(items.get(6).get(position));
// likes.setText(items.get(7).get(position));
// upvote.setText(items.get(8).get(position));
// downvote.setText(items.get(9).get(position));
// desc.setText(items.get(4).get(position));
// pub.setText(items.get(5).get(position));
// idnum.setText(items.get(0).get(position));
return rowView;
}
}
logcat 中没有错误。
这里有什么问题?