-1

我想要一个简单的 a 片段,ListView它由从也使用getView()方法的数据集数组中获取的项目组成。ListView仅包含与文本和图像不同的文本条目。

4

1 回答 1

0

http://www.ezzylearning.com/tutorial.aspx?tid=1763429

 <TextView android:id="@+id/txtTitle"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_vertical"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:textStyle="bold"
    android:textSize="22dp"
    android:textColor="#000000"
    android:layout_marginTop="5dp"
    android:layout_marginBottom="5dp" />

@Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; WeatherHolder持有人=空;

    if(row == null)
    {
        LayoutInflater inflater = ((Activity)context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);

        holder = new WeatherHolder();
        holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);

        row.setTag(holder);
    }
    else
    {
        holder = (WeatherHolder)row.getTag();
    }

    Weather weather = data[position];
    holder.txtTitle.setText(weather.title);

    return row;
}
于 2013-01-16T17:41:56.650 回答