public List
{
List
try
{
string sql = "select * from C";
SqlCommand cmd = new SqlCommand(sql,sqlCon);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
//将结果集信息添加到返回向量中
list.Add(reader[0].ToString());
list.Add(reader[1].ToString());
list.Add(reader[2].ToString());
}
reader.Close();
cmd.Dispose();
}
catch(Exception)
{
}
return list;
}
|
private void setListView() {
listView.setVisibility(View.VISIBLE);
List
list = dbUtil.getAllInfo();
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);
}
|
public List
List
arrayList.clear();
brrayList.clear();
crrayList.clear();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
crrayList = Soap.GetWebServre("selectAllCargoInfor", arrayList, brrayList);
}
}).start();
HashMap
tempHash.put("Cno", "Cno");
tempHash.put("Cname", "Cname");
tempHash.put("Cnum", "Cnum");
list.add(tempHash);
for (int j = 0; j < crrayList.size(); j += 3) {
HashMap
hashMap.put("Cno", crrayList.get(j));
hashMap.put("Cname", crrayList.get(j + 1));
hashMap.put("Cnum", crrayList.get(j + 2));
list.add(hashMap);
}
return list;
}
|
05-02 15:51:40.642: I/System.out(3678):
05-02 15:51:40.647: I/System.out(3678):
05-02 15:51:40.647: I/System.out(3678): soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
05-02 15:51:40.647: I/System.out(3678): soap:Body
05-02 15:51:40.647: I/System.out(3678): selectAllCargoInforResponse xmlns="http://tempuri.org/"
05-02 15:51:40.647: I/System.out(3678): selectAllCargoInforResult
05-02 15:51:40.647: I/System.out(3678): 0
05-02 15:51:40.647: I/System.out(3678): string>1
05-02 15:51:40.647: I/System.out(3678): string>rice
05-02 15:51:40.647: I/System.out(3678): string>100
05-02 15:51:40.647: I/System.out(3678): string>2
05-02 15:51:40.652: I/System.out(3678): string>dog
05-02 15:51:40.652: I/System.out(3678): string>50
05-02 15:51:40.652: I/System.out(3678): string>3
05-02 15:51:40.652: I/System.out(3678): string>白痴
05-02 15:51:40.652: I/System.out(3678): string>25
05-02 15:51:40.652: I/System.out(3678): /selectAllCargoInforResult
05-02 15:51:40.652: I/System.out(3678): 1
|
private final static int REQUEST_SUCCESS = 1;
private final static int REQUEST_FALSE = 0;
private void RequestData()
{
arrayList.clear();
brrayList.clear();
crrayList.clear();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
crrayList = Soap.GetWebServre("selectAllCargoInfor", arrayList, brrayList);
Message msg = new Message();
if(crrayList.size()>0)
{
msg.what = REQUEST_SUCCESS;
}
else
{
msg.what = REQUEST_FALSE;
}
// 发送消息
mHandler.sendMessage(msg);
}
}).start();
}
public Handler mHandler = new Handler(){
// 接收消息
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
switch (msg.what)
{
case REQUEST_SUCCESS:
setListView();
break;
case REQUEST_FALSE:
// 做错误处理
break;
default:
break;
}
}
};
private void setListView() {
listView.setVisibility(View.VISIBLE);
List
list = dbUtil.getAllInfo();
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);
}
public List
List
HashMap
tempHash.put("Cno", "Cno");
tempHash.put("Cname", "Cname");
tempHash.put("Cnum", "Cnum");
list.add(tempHash);
for (int j = 0; j < crrayList.size(); j += 3) {
HashMap
hashMap.put("Cno", crrayList.get(j));
hashMap.put("Cname", crrayList.get(j + 1));
hashMap.put("Cnum", crrayList.get(j + 2));
list.add(hashMap);
}
return list;
}
|