所以我正在实时列表视图中工作,我需要列表视图以在单击按钮时进行更新,所以这些操作如下:private void ReloadData(){ DataList.clear(); try{ for (int i =0;i<ItemsCount;i++){ TempItem=new STRUCTS.STRUCT_ProductItem(); TempItem.setName(dbh.ReadDefine(ProductID,i+"","name")+"");//Read name if there is any set TempItem.setImgs(Uri.parse(dbh.ReadDefine(ProductID,i+"","img")+""));//Read image if there is any set TempItem.setInfo("PR"+i);//Desc Log.i("TAG", "ReloadData: "+IsOn[i]);//Is product avalible TempItem.setToggled(IsOn[i]); DataList.add(TempItem); } }catch (Exception ex){ ex.printStackTrace(); Log.e("ERRORCATCHER", "OnForLoop (Fill Product Data): "+ex.getMessage() ); } // if(!IsAdapterSet){ adapter = new LISTCUSTOM_ProductITEM(MyActivity.this,DataList); list.setAdapter(adapter); IsAdapterSet=true; }else{ try { adapter.swapItems(DataList); } catch (Exception e) { e.printStackTrace(); } }}我的自定义适配器上的SwapItems: public void swapItems(ArrayList<STRUCTS.STRUCT_ProductItem> list) throws InterruptedException { DataList=list; this.notifyDataSetChanged();}这没有给出任何错误,正如我从“日志”中看到的那样,新项已成功添加,并且其数据是新的listview不会更新自己!因此,当我单击运行ReloadData()的按钮时,它对列表视图没有任何影响...暂时正在运行此日志: @Override public View getView(final int CPosition, @Nullable View convertView, @NonNull ViewGroup parent) { final STRUCTS.STRUCT_ProductItem Currect_Item=DataList.get(CPosition); Log.i("TAG", "View updated : "+Currect_Item.gettoggled());/*Define stuff*/ itempicture.setImageURI(Currect_Item.getImgs());/*More listview update stuff*/当我单击该按钮时,它不会记录ViewUpdated,也不会更改任何listview元素但是,当我滚动列表视图时,因此看不到任何项,然后向后滚动,它们的数据将被更新!当项目失去可见性然后再次获得它时,将运行GetView为什么Notifydatachanged不会更新UI /在自定义适配器上运行GetView?
添加回答
举报
0/150
提交
取消