查询Listview 只有标题名,没有内容;删除插入都没有问题!Web下要询没有问题,(原贴是没有加线程的,偶的是4.0所以开始都无法执行,修改原代码后 插入,删除都可以了,但是listView 还是显示空白)
部分代码如下
1, DBUtil 类
List<HashMap<String,String>> list1=new ArrayList<HashMap<String,String>>();
public List<HashMap<String,String>> getAllInfo(final Handler myhandler) {
//List<HashMap<String, String>> list1 = new ArrayList<HashMap<String, String>>();
arrayList.clear();
list1.clear();
// brrayList.clear();
// crrayList.clear();
HashMap<String,String> tempHash = new HashMap<String,String>();
tempHash.put(“Cno”, “Cno”);
tempHash.put(“Cname”, “Cname”);
tempHash.put(“Cnum”, “Cnum”);
list1.add(tempHash);
new Thread(){
public void run()
{
try{
crrayList = Soap.GetWebServre(“selectAllCargoInfor”, arrayList, brrayList);
Message msg=new Message();
msg.what=0x123;
msg.obj=arrayList;
myhandler.sendMessage(msg);
}
catch(Exception e) {
}
}
}.start();
return list1;
}
2 MainActivity 类如下
btn1.setOnClickListener(new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO 自动生成的方法存根
hideButton(true);
setListView();
}
});
List<HashMap<String,String>> list=new ArrayList<HashMap<String,String>>();
final Handler myhandler=new Handler()
{
public void handleMessage(Message msg){
if(msg.what==0x123) {
ArrayList<String> crrayList=(ArrayList<String>) msg.obj;
for(int j=0;j< crrayList.size();j+=3)
{
HashMap<String,String> hashMap=new HashMap<String, String>();
hashMap.put(“Cno”,crrayList.get(j));
hashMap.put(“Cname”,crrayList.get(j+1));
hashMap.put(“Cnum”,crrayList.get(j+2));
list.add(hashMap);
}
adapter = new SimpleAdapter(
MainActivity.this,
list,
R.layout.adapter_item,
new String[] {“Cno”,”Cname”,”Cnum”},
new int[] {R.id.txt_Cno,R.id.txt_Cname,R.id.txt_Cnum});
listView.setAdapter(adapter);
}
}
};
private void setListView() {
listView.setVisibility(View.VISIBLE);
list = dbUtil.getAllInfo(myhandler);
}
不知道哪里错误,请大牛指点,谢谢!
50