BillQuery
作者:互联网
package com.example.wms;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.wms.entity.BillQueryEntity;
import com.example.wms.util.HttpHelper;
import com.google.gson.Gson;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
import java.util.Map;
public class BillQuery extends AppCompatActivity {
private ListView listView_main_news;
private List<Map<String, String>> list_map = null;
private ImageButton btn_1;
private Button btn_2;
private String result = "";
private Button queryboxNoBill;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bill_query);
btn_1 = findViewById(R.id.fh_btn);
btn_1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
//查找数据按钮
btn_2 = findViewById(R.id.btn_queryboxStock);
btn_2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/* //把listView中的值传入listView_Stock_Query列表控件
listView_main_news = (ListView) findViewById(R.id.lv_stock);
//把测试数据添加到集合循环遍历
list_map = new ArrayList<Map<String, String>>();
for (int i = 0; i < 30; i++) {
Map<String, String> map = new HashMap<String, String>();
map.put("username", "wangxiangjun_" + i);
map.put("password", "123456_" + i);
list_map.add(map);
}
// 使用SimpleAdapter来作为ListView的适配器,比ArrayAdapter能展现更复杂的布局效果。
// 为了显示较为复杂的ListView的item效果,需要写一个xml布局文件,来设置ListView中每一个item的格式。
SimpleAdapter adapter = new SimpleAdapter(StockQuery.this, list_map,
R.layout.activity_stock, new String[] { "username",
"password" }, new int[] {
R.id.stockId,
R.id.stockStatus });
listView_main_news.setAdapter(adapter);*/
listView_main_news = (ListView) findViewById(R.id.lv_bill);
listView_main_news.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BillQueryEntity billQueryEntity=new BillQueryEntity();
queryboxNoBill=findViewById(R.id.btn_queryboxNoBill);
billQueryEntity.setOrdernumber(queryboxNoBill.getText().toString());
//实体类转化为JSON
Gson gson = new Gson();
String value = gson.toJson(billQueryEntity);
JSONObject root = new JSONObject();
try {
//存data的值
root.put("encrypttokenno", HttpHelper.EncryptTokenNo);//token值
root.put("apptype", HttpHelper.AppType);
root.put("AppDeviceNo",HttpHelper.AppDeviceNo);//mac地址
root.put("IPAddress",HttpHelper.IPAddress);//ip
root.put("JsonData",value);
} catch (JSONException e) {
e.printStackTrace();
}
result = Post_Info(root.toString());
}
});
}
protected String Post_Info(String json){
return HttpHelper.Post(HttpHelper.url_StockQuery,json);
}
});
}
}
标签:map,listView,BillQuery,new,put,import,btn 来源: https://www.cnblogs.com/changanyi/p/16354680.html