本邮件内容由第三方提供,如果您不想继续收到该邮件,可 点此退订 。  
  新加坡架构师面试总结  阅读原文»
android ListView常用知识总结  阅读原文»                                                                                                                                    
                用户名:王宇斌                文章数:3                评论数:5
                访问量:1132:1364:94:1                注册日期:2013-03-22
                    先来看下项目主要内容:
                    
ListView中填充数据:
-                       
重现添加数据后置顶,具体阐明了决解方案,如下:
 -                       
刷新适配器后没有响应的错误现象,具体阐明了决解方案,如下:
 -                       
正确示范一:
* 正确示范一(正确运用,修改原始对象<Activity里面>对应引用<Adapter里面>也改变)publicclassThreeListViewActivityextendsActivity {privateListView mContentLv;privateOneAdapter adapter;privateArrayList<HashMap<String, String>> arrayList=newArrayList<HashMap<String,String>>();protectedvoidonCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.activity_listview);mContentLv = (ListView) findViewById(R.id.lv_content);adapter=newOneAdapter(this,arrayList);mContentLv.setAdapter(adapter);ToastUtils.show(getApplicationContext(),"6秒后延迟添加,刷新adapter");privatevoidsetData() {newThread(newRunnable() {publicvoidrun() {// TODO Auto-generated method stub//做一些耗时的操作后添加数据,之后刷新adapterThread.sleep(6000);}catch(InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();//可能这个时候才重网络上获取到了新数据,,现在开始添加数据HashMap<String, String> hashMap;for(inti =0; i <5; i++) {hashMap =newHashMap<String, String>();hashMap.put("name","大海");hashMap.put("address","上海");}elseif(i %4==1) {hashMap.put("name","老马");hashMap.put("address","深圳");}elseif(i %4==2) {hashMap.put("name","小三");hashMap.put("address","东莞");}elseif(i %4==3) {hashMap.put("name","老哥");hashMap.put("address","北京");arrayList.add(hashMap);handler.sendEmptyMessage(1);订阅: 博文评论 (Atom) 
没有评论:
发表评论