如何创建一个无尽的ListView,如果我的程序是使用垂直listView,我使用这个site添加不会编写knit,但还没有弄清楚如何使用它。所以我需要做listView痴迷,不太明白它是如何实现的。 这里是创建它的聊天代码:
public void onCreate(Bundle savedInstanceState) {
..
HorizontalListView listview = (HorizontalListView) findViewById(R.id.listview);
listview.setAdapter(mAdapter);
}
private static String[] dataObjects = new String[]{ "Text #1",
"Text #2",
"Text #3","Text #3","Text #3" };
private BaseAdapter mAdapter = new BaseAdapter() {
ArrayList<Object> objects;
@Override
public int getCount() {
return dataObjects.length;//
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View retval = LayoutInflater.from(parent.getContext()).inflate(R.layout.listview_leyout, null);
TextView title = (TextView) retval.findViewById(R.id.title);
title.setText(dataObjects[position]);
return retval;
}
答案 0 :(得分:1)
CHange getCount返回一个巨大的数字
@Override
public int getCount() {
return Integer.MAX_VALUE;//
}
当然
title.setText(dataObjects[position]);
应该是
title.setText(dataObjects[position%dataObjects.lenght]);