我有需要从 url 下载数据并将其显示在 listview 中的新闻应用程序,但我希望第一行与其他行不同,因为在那里将显示主要新闻可以说,我有这个适配器类来显示所有行相同,而且我不能修改它来做我上面写的,有人可以帮我吗
这是适配器类的代码
public class LazyAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null){
vi = inflater.inflate(R.layout.list_row, null);
}
TextView title = (TextView)vi.findViewById(R.id.title); // title
//TextView artist = (TextView)vi.findViewById(R.id.artist); // artist name
TextView author = (TextView)vi.findViewById(R.id.einfo1); // duration
TextView datetime = (TextView)vi.findViewById(R.id.einfo);
TextView story = (TextView)vi.findViewById(R.id.einfo2);
ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image
HashMap<String, String> n = new HashMap<String, String>();
n = data.get(position);
// Setting all values in listview
title.setText(n.get(Home.TAG_TITLE));
author.setText(n.get(Home.TAG_AUTHOR));
datetime.setText(n.get(Home.TAG_DATETIME));
story.setText(n.get(Home.TAG_STORY));
thumb_image.setTag(n.get(Home.TAG_IMG));
imageLoader.DisplayImage(n.get(Home.TAG_IMG), thumb_image);
return vi;
}
}