`
liangoogle
  • 浏览: 278332 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

ListViewAdapter extends BaseAdapter

    博客分类:
  • view
 
阅读更多

让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; } } 

分享到:
评论

相关推荐

    listview adapter

    it's a normal Android listview adapter.The adapter extends BaseAdapter...

    ListViewLoadMore

    public class ListViewAdapter extends BaseAdapter { private Map,View&gt; m=new HashMap,View&gt;(); private List&lt;String&gt; items; private LayoutInflater inflater; public ListViewAdapter...

    ListView嵌套GridView解决方案

    public class ListViewAdapter extends BaseAdapter { private List&lt;List&lt;String&gt;&gt; data; // 构造函数,初始化数据 // ... @Override public View getView(int position, View convertView, ViewGroup parent) ...

    ListView和Button的结合使用

    public class ListViewAdapter extends BaseAdapter { // ... @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = ...

    listview 通过继承BaseAdapter来实现

    public class MyAdapter extends BaseAdapter { private List&lt;String&gt; dataList; public MyAdapter(List&lt;String&gt; dataList) { this.dataList = dataList; } @Override public int getCount() { return ...

    Android之自定义Adapter的ListView

    public class ListViewAdapter extends BaseAdapter { // ...其他成员变量的声明 @Override public int getCount() { return listItems.size(); } @Override public Object getItem(int position) { ...

    listview嵌套

    public class ListViewAdapter extends BaseAdapter { private List&lt;ItemData&gt; dataList; @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if ...

    android studio实现listview的增加,左滑删除

    public class ListViewAdapter extends BaseAdapter { private Context context; private List&lt;String&gt; dataList; // 构造函数,初始化数据和上下文 public ListViewAdapter(Context context, List&lt;String&gt; ...

    ListView的使用自定义BaseAdapter

    public class MyAdapter extends BaseAdapter { private List&lt;String&gt; dataList; public MyAdapter(List&lt;String&gt; dataList) { this.dataList = dataList; } @Override public int getCount() { return ...

    listviewAdapter

    public class NewsListViewAdapter extends BaseAdapter { List&lt;News&gt; list; LayoutInflater inflater; Context context; public NewsListViewAdapter(List&lt;News&gt; list, Context context) { super(); this....

    wzy17419.rar

    class ListViewAdapter extends BaseAdapter { @Override public int getCount() { return news.size(); } @Override public News getItem(int position) { return news.get(position); } ...

    ListView Adapter优化 实例

    代码如下://方案一 – adapter优化public class listviewAdapterDemo1 extends BaseAdapter {  private String[] mArrData; private ListView listView; private AsyncImageLoader asyncImageLoader; private ...

    Android中ListView常用方式:使用BaseAdapter

    public class ListAdapter extends BaseAdapter { private Context context; private List&lt;DataItem&gt; dataList; public ListAdapter(Context context, List&lt;DataItem&gt; dataList) { this.context = context; ...

    Android开发中ListView自定义adapter的封装

    【引入】  我们一般编写listView的时候顺序是这样的: ...List&lt;T&gt;:ListView –&gt; Adapter extends BaseAdapter –&gt; ViewHolder  一般情况下,一个ListView对应一个Adapter类,对应一个ViewHolder类,那如果一个app中

    BaseAdapter_listview

    public class MyAdapter extends BaseAdapter { private List&lt;String&gt; dataList; public MyAdapter(List&lt;String&gt; dataList) { this.dataList = dataList; } @Override public int getCount() { return ...

    实现ListView过滤功能,继承于BaseAdapter,非ArrayAdapter。

    在本教程中,我们将探讨如何实现一个基于BaseAdapter而非ArrayAdapter的ListView过滤功能。 首先,理解BaseAdapter与ArrayAdapter的区别是重要的。ArrayAdapter是预设的适配器,它直接绑定到一个数组或ArrayList...

    Android自定义Adapter的ListView的思路及代码

    public class ListViewAdapter extends BaseAdapter { private Context context; private List, Object&gt;&gt; data; public ListViewAdapter(Context context, List, Object&gt;&gt; data) { this.context = context; ...

    Android中ListView,SQLite,BaseAdapter的结合

    ### Android中ListView、SQLite与BaseAdapter的结合应用 在Android开发中,经常需要处理列表数据展示及后台数据库操作。本文将详细介绍如何通过ListView组件、SQLite数据库以及BaseAdapter自定义适配器来实现一个...

    Android使用ListView批量删除item的方法

    public class ListVIewAdapter extends BaseAdapter { private Context context; private List&lt;String&gt; strList; private List&lt;Boolean&gt; boolList; // 构造函数 public ListVIewAdapter(Context context) { ...

    ListView嵌套GridView使用详解及注意事项

    public class ListViewAdapter extends BaseAdapter { private ArrayList, Object&gt;&gt;&gt; mData; private Context mContext; public ListViewAdapter(ArrayList, Object&gt;&gt;&gt; data, Context context) { this.mData = ...

Global site tag (gtag.js) - Google Analytics