我是 ArrayAdapter 的子类,但是通过 getView 的视图是空的?这是为什么?
我必须在 getView 方法中手动指定视图。发送到此方法的视图从何而来?
public class CustomList2 extends ArrayAdapter<String>
{
public CustomList2(Context context, int layout_id, ArrayList<String> objects){
super(context, layout_id, objects);
}
@Override
public View getView(final int position, View view, ViewGroup view_group) {
if(view == null)
{
LayoutInflater inflater = getLayoutInflater();
view = inflater.inflate(R.layout.customlist, null);
}
return view;
}
}
适配器和视图设置如下:
video_list = (ListView)findViewById(R.id.list);
video_list.setAdapter(adapter);