让listview滑动时不改变背景色
xml布局文件里设置为:
android:cacheColorHint="#00000000"
java代码里设置为:
listView.setCacheColorHint(0);
或
gridView.setCacheColorHint(0);
public class ListViewAdapter extends BaseAdapter {
Context context;
ArrayList<string> arrayList;
LayoutInflater inflater;
public ListViewAdapter(Context context, ArrayList<string> arrayList)
{
this.context = context;
this.arrayList = arrayList;
//获取这个布局变量。
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount()
{
// TODO Auto-generated method stub
return arrayList.size();
}
@Override
public Object getItem(int position)
{
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position)
{
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
ViewHolder viewHolder;
if (convertView == null)
{
viewHolder = new ViewHolder();
convertView = inflater.inflate(R.layout.toobaritem_menu, null);
//这是用一个布局来填充这个View ,每个View 都是一条listview
viewHolder.contentTextView = (TextView) convertView.findViewById(R.id.title_text);
viewHolder.icon=(ImageView) convertView.findViewById(R.id.icon_image);
viewHolder.icon.setImageResource(R.drawable.album_normal);
viewHolder.icon.setPadding(0, 5, 10, 5);
convertView.setTag(viewHolder);
}
else
{
viewHolder = (ViewHolder) convertView.getTag();
}
String path = arrayList.get(position);
String name = path.substring(path.lastIndexOf("/") + 1,
path.length() - 4);
viewHolder.contentTextView.setText(name);
viewHolder.contentTextView.setTextSize(25);
return convertView;
}
static class ViewHolder
{
ImageView icon;
TextView contentTextView;
}
}
分享到:
相关推荐
it's a normal Android listview adapter.The adapter extends BaseAdapter...
public class ListViewAdapter extends BaseAdapter { private Map,View> m=new HashMap,View>(); private List<String> items; private LayoutInflater inflater; public ListViewAdapter...
public class ListViewAdapter extends BaseAdapter { private List<List<String>> data; // 构造函数,初始化数据 // ... @Override public View getView(int position, View convertView, ViewGroup parent) ...
public class ListViewAdapter extends BaseAdapter { // ... @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = ...
public class MyAdapter extends BaseAdapter { private List<String> dataList; public MyAdapter(List<String> dataList) { this.dataList = dataList; } @Override public int getCount() { return ...
public class ListViewAdapter extends BaseAdapter { // ...其他成员变量的声明 @Override public int getCount() { return listItems.size(); } @Override public Object getItem(int position) { ...
public class ListViewAdapter extends BaseAdapter { private List<ItemData> dataList; @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if ...
public class ListViewAdapter extends BaseAdapter { private Context context; private List<String> dataList; // 构造函数,初始化数据和上下文 public ListViewAdapter(Context context, List<String> ...
public class MyAdapter extends BaseAdapter { private List<String> dataList; public MyAdapter(List<String> dataList) { this.dataList = dataList; } @Override public int getCount() { return ...
public class NewsListViewAdapter extends BaseAdapter { List<News> list; LayoutInflater inflater; Context context; public NewsListViewAdapter(List<News> list, Context context) { super(); this....
class ListViewAdapter extends BaseAdapter { @Override public int getCount() { return news.size(); } @Override public News getItem(int position) { return news.get(position); } ...
代码如下://方案一 – adapter优化public class listviewAdapterDemo1 extends BaseAdapter { private String[] mArrData; private ListView listView; private AsyncImageLoader asyncImageLoader; private ...
public class ListAdapter extends BaseAdapter { private Context context; private List<DataItem> dataList; public ListAdapter(Context context, List<DataItem> dataList) { this.context = context; ...
【引入】 我们一般编写listView的时候顺序是这样的: ...List<T>:ListView –> Adapter extends BaseAdapter –> ViewHolder 一般情况下,一个ListView对应一个Adapter类,对应一个ViewHolder类,那如果一个app中
public class MyAdapter extends BaseAdapter { private List<String> dataList; public MyAdapter(List<String> dataList) { this.dataList = dataList; } @Override public int getCount() { return ...
在本教程中,我们将探讨如何实现一个基于BaseAdapter而非ArrayAdapter的ListView过滤功能。 首先,理解BaseAdapter与ArrayAdapter的区别是重要的。ArrayAdapter是预设的适配器,它直接绑定到一个数组或ArrayList...
public class ListViewAdapter extends BaseAdapter { private Context context; private List, Object>> data; public ListViewAdapter(Context context, List, Object>> data) { this.context = context; ...
### Android中ListView、SQLite与BaseAdapter的结合应用 在Android开发中,经常需要处理列表数据展示及后台数据库操作。本文将详细介绍如何通过ListView组件、SQLite数据库以及BaseAdapter自定义适配器来实现一个...
public class ListVIewAdapter extends BaseAdapter { private Context context; private List<String> strList; private List<Boolean> boolList; // 构造函数 public ListVIewAdapter(Context context) { ...
public class ListViewAdapter extends BaseAdapter { private ArrayList, Object>>> mData; private Context mContext; public ListViewAdapter(ArrayList, Object>>> data, Context context) { this.mData = ...