为什么以及如何,这一行正在处理整个数组label.setText(items[position]); 没有任何循环条件!
这是我的,正在访问 array_adapter 类的类。对于资源....
class FunnyLookingAdapter extends ArrayAdapter
{
Context ctxt;
FunnyLookingAdapter(Context ctxt, int resource,String[] items)
{
super(ctxt, resource, items);
this.ctxt=ctxt;
}
public View getView(int position, View convertView,ViewGroup parent)
{
TextView label=(TextView)convertView;
if (convertView==null)
{
convertView=new TextView(ctxt);
label=(TextView)convertView;
}
label.setText(items[position]); //------------------ this is the line !
return(convertView);
}
}
而这一阶段的代码使用的是前一个类。所以代码是::
GridView grd = ( GridView ) findViewById ( R.id.gd_v );
grd.setAdapter(new FunnyLookingAdapter(this,
android.R.layout.simple_list_item_1,
items));
并且字符串资源数组是:
String[] items={"lorem", "ipsum", "dolor", "sit", "amet",
"consectetuer", "adipiscing", "elit", "morbi", "vel",
"ligula", "vitae", "arcu", "aliquet", "mollis",
"etiam", "vel", "erat", "placerat", "ante",
"porttitor", "sodales", "pellentesque", "augue", "purus"};