- 浏览: 3369625 次
- 性别:
- 来自: 珠海
文章分类
- 全部博客 (1633)
- Java (250)
- Android&HTML5 (111)
- Struts (10)
- Spring (236)
- Hibernate&MyBatis (115)
- SSH (49)
- jQuery插件收集 (55)
- Javascript (145)
- PHP (77)
- REST&WebService (18)
- BIRT (27)
- .NET (7)
- Database (105)
- 设计模式 (16)
- 自动化和测试 (19)
- Maven&Ant (43)
- 工作流 (36)
- 开源应用 (156)
- 其他 (16)
- 前台&美工 (119)
- 工作积累 (0)
- OS&Docker (83)
- Python&爬虫 (28)
- 工具软件 (157)
- 问题收集 (61)
- OFbiz (6)
- noSQL (12)
最新评论
-
HEZR曾嶸:
你好博主,这个不是很理解,能解释一下嘛//左边+1,上边+1, ...
java 两字符串相似度计算算法 -
天使建站:
写得不错,可以看这里,和这里的这篇文章一起看,有 ...
jquery 遍历对象、数组、集合 -
xue88ming:
很有用,谢谢
@PathVariable映射出现错误: Name for argument type -
jnjeC:
厉害,困扰了我很久
MyBatis排序时使用order by 动态参数时需要注意,用$而不是# -
TopLongMan:
非常好,很实用啊。。
PostgreSQL递归查询实现树状结构查询
1.创建跟Android无关的Domain
2.创建Android有关的Domain(使用Tag方式)
3.直接使用
package com.jiangqq.csdn; public class Person { private String personName; private String personAddress; public Person(String personName, String personAddress) { super(); this.personName = personName; this.personAddress = personAddress; } public String getPersonName() { return personName; } public void setPersonName(String personName) { this.personName = personName; } public String getPersonAddress() { return personAddress; } public void setPersonAddress(String personAddress) { this.personAddress = personAddress; } }
package com.jiangqq.csdn; import java.util.List; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; /** * 自定义适配器类 * @author jiangqq <a href=http://blog.csdn.net/jiangqq781931404></a> * */ public class MyAdapter extends BaseAdapter { private List<Person> mList; private Context mContext; public MyAdapter(Context pContext, List<Person> pList) { this.mContext = pContext; this.mList = pList; } @Override public int getCount() { return mList.size(); } @Override public Object getItem(int position) { return mList.get(position); } @Override public long getItemId(int position) { return position; } /** * 下面是重要代码 */ @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater _LayoutInflater=LayoutInflater.from(mContext); convertView=_LayoutInflater.inflate(R.layout.item, null); if(convertView!=null) { TextView _TextView1=(TextView)convertView.findViewById(R.id.textView1); TextView _TextView2=(TextView)convertView.findViewById(R.id.textView2); _TextView1.setText(mList.get(position).getPersonName()); _TextView2.setText(mList.get(position).getPersonAddress()); } return convertView; } }
// 初始化控件 mSpinner = (Spinner) findViewById(R.id.spinner1); // 建立数据源 List<Person> persons=new ArrayList<Person>(); persons.add(new Person("张三", "上海 ")); persons.add(new Person("李四", "上海 ")); persons.add(new Person("王五", "北京" )); persons.add(new Person("赵六", "广州 ")); // 建立Adapter绑定数据源 MyAdapter _MyAdapter=new MyAdapter(this, persons); //绑定Adapter mSpinner.setAdapter(_MyAdapter);
2.创建Android有关的Domain(使用Tag方式)
package com.pandy.db.adapter; import android.widget.ImageView; import android.widget.TextView; /** * Created with IntelliJ IDEA. * User: pandy * Date: 13-6-26 * Time: 下午3:48 * To change this template use File | Settings | File Templates. */ public class SettingListDomain { private ImageView sfls_imageView; private TextView sfls_title; private TextView sfls_desc; public TextView getSfls_title() { return sfls_title; } public TextView getSfls_desc() { return sfls_desc; } public ImageView getSfls_imageView() { return sfls_imageView; } public void setSfls_imageView(ImageView sfls_imageView) { this.sfls_imageView = sfls_imageView; } public void setSfls_title(TextView sfls_title) { this.sfls_title = sfls_title; } public void setSfls_desc(TextView sfls_desc) { this.sfls_desc = sfls_desc; } }
package com.pandy.db.adapter; import android.app.Activity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; import com.pandy.db.R; import java.util.List; import java.util.Map; /** * Created with IntelliJ IDEA. * User: pandy * Date: 13-6-26 * Time: 下午3:09 * To change this template use File | Settings | File Templates. */ public class SettingListAdapter extends BaseAdapter { private Activity activity; private List<Map<String, Object>> data; private LayoutInflater layoutInflater; public SettingListAdapter(Activity activity, List<Map<String, Object>> data) { this.activity = activity; this.data = data; this.layoutInflater = LayoutInflater.from(this.activity); } @Override public int getCount() { return data.size(); //To change body of implemented methods use File | Settings | File Templates. } @Override public Object getItem(int i) { return data.get(i); //To change body of implemented methods use File | Settings | File Templates. } @Override public long getItemId(int i) { return i; //To change body of implemented methods use File | Settings | File Templates. } @Override public View getView(int i, View view, ViewGroup viewGroup) { SettingListDomain domain = null; if (view == null) { domain = new SettingListDomain(); view = layoutInflater.inflate(R.layout.setting_fun_list_sub, null); domain.setSfls_imageView((ImageView) view.findViewById(R.id.sfls_imageView)); domain.setSfls_title((TextView) view.findViewById(R.id.sfls_title)); domain.setSfls_desc((TextView) view.findViewById(R.id.sfls_desc)); view.setTag(domain); } else { domain = (SettingListDomain) view.getTag(); } // domain.getSfls_imageView().setBackgroundColor((Integer) data.get(i).get("sfls_imageView")); domain.getSfls_imageView().setImageResource((Integer) data.get(i).get("sfls_imageView")); domain.getSfls_title().setText((String) data.get(i).get("sfls_title")); domain.getSfls_desc().setText((String) data.get(i).get("sfls_desc")); return view; } }
sfl_listView = (ListView) findViewById(R.id.sfl_listView); SettingListAdapter adapter = new SettingListAdapter(this, SystemDataUtils.getSettingFunListData(SettingFunListActivity.this)); try { sfl_listView.setAdapter(adapter); sfl_listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Map<String, Object> map = (Map<String, Object>) adapterView.getAdapter().getItem(i); doSetting(map.get("sfls_title").toString()); } }); } catch (Exception e) { ToastUtils.show(this, e); }
3.直接使用
package com.gv; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; public class ImageAdapder extends BaseAdapter { private Context context; private int[] images; public ImageAdapder(Context context,int[] images){ this.context = context; this.images = images; } @Override public int getCount() { // TODO Auto-generated method stub return images.length; } @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) { ImageView imageView = new ImageView(context); imageView.setImageResource(images[position]); return imageView; } }
发表评论
-
html5调用手机拍照并压缩上传
2016-06-24 15:36 1178http://my.oschina.net/zyxchuxin ... -
HTML调用PC摄像头
2016-04-06 09:31 1688http://www.oschina.net/code/sni ... -
微信JS-SDK获取signature签名以及config配置
2016-02-16 11:31 3106原文看:http://1017401036.iteye.com ... -
Html5添加移动触摸的网页版PDF格式文件阅读器插件
2016-01-07 15:30 1856http://my.oschina.net/u/2505907 ... -
js canvas 照片旋转 demo
2015-12-26 17:52 1490http://my.oschina.net/u/1259707 ... -
静态网站生成器 Lektor
2015-11-18 09:24 1244http://www.oschina.net/p/lektor ... -
history.js 一个无刷新就可改变浏览器栏地址的插件(不依赖jquery)
2015-11-10 21:27 1064http://ourjs.com/detail/5507ed1 ... -
如何使用js、html5在浏览器直接打开pdf文档
2015-11-03 22:32 8630http://q.cnblogs.com/q/48507/ ... -
HTML5 Geolocation API的使用方法及实现原理
2015-10-28 22:05 1618百度地图 百度地图为什 ... -
jquery三种支持手机触屏的插件库
2015-10-28 14:30 1322http://my.oschina.net/u/2395167 ... -
Android 应用热修复工具 AndFix
2015-09-16 08:42 1302http://www.oschina.net/p/andfix ... -
【gloomyfish】关于手机网站你想知道的一切
2015-09-15 21:48 846http://blog.csdn.net/jia20003/a ... -
java 判断请求来自手机或电脑
2015-09-15 21:42 947java 判断 android、iphone等 ... -
Cordova例子
2014-11-21 17:11 2892官方文档:http://cordova.apache.org/ ... -
Android AVD创建及设置中各参数详解
2014-11-19 16:49 1198http://zhongyankeji.blog.163.co ... -
PhoneGap的例子
2014-11-19 10:06 2386cordova命令行详解: http: ... -
Zepto.js与jquery的比较
2014-11-12 15:49 1829http://my.oschina.net/u/1791195 ... -
在android的webview中实现websocket
2014-07-23 21:29 2040在android的webview中实现websocket ht ... -
原生:在Android开发中调用Restful web服务
2014-07-23 21:27 1673在Android开发中调用Rest web服务 http:// ... -
Android+REST WebService服务方式手机开发
2014-07-23 21:27 867Android+REST WebService服务方式手机开发 ...
相关推荐
baseadapter
Android-扩展BaseAdapter实现progressBar下载 * 该Demo涉及了BaseAdapter,ProgressBar,Handler,Thread,线程池; * * Android-扩展BaseAdapter实现progressBar下载 * 1.创建listview的xml * 2.创建listview中...
ListView与BaseAdapter的配套使用 理解android 中adapter适配的作用 以及ListView的优化方式
高度封装的baseAdapter
BaseAdapter博客事例源代码
怎样使用BaseAdapter
ListView和BaseAdapter搭配Button点击事件获取不同Item
android demo,BaseAdapter传递context的应用,
本项目主要使用到BaseAdapter和Sqlite数据库,在主界面中有输入数据的EditText数据输入完成后点击添加按钮,设局会保存到Sqlite数据库中,同时会在下面的ListView中显示您刚才输入的数据,ListView使用的适配器为...
用BaseAdapter实现的ListView,留着自己备用哈。
baseAdapter使用详细说明 完整的注释 完美的框架、优化等 学习android列表必看
使用BaseAdapter必须写一个类继承它,同时BaseAdapter是一个抽象类,继承它必须实现它的方法
一个简单baseAdapter的封装demo.减少一些不必须要的重复的代码。
android demo,baseAdapter的应用,
android中自定义适配器BaseAdapter
主要是测试baseAdapter的getView在生成实例时的空判断进行接卸
SimpleAdapter BaseAdapter 基本使用
自定义BaseAdapter操作步骤实现Listview的界面显示,操作简易
Android中ListView,SQLite,BaseAdapter的结合源码
Android必学-BaseAdapter的使用与优化,写出高效、文艺的BaseAdapter, android studio环境