private class loadAsyncTask extends AsyncTask<String, Integer, String> {
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(DishesListActivity.this, "提示", "获取中..");
}
@Override
protected String params) {
String json = null;
serverUrl = AppConstant.getUrl(getApplicationContext()) + "ServletService?Action=getdisheslist&msg="
+ params[0];
json = httpHelper.HttpRequest(serverUrl);
return json;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
dialog.dismiss();
list = new ArrayList<dishes>();
if (result != null && im().length() > 0) {
try {
jsonArray = new JSONArray(result);
for (int i = 0; i < jsonArray.length(); i++) {
jsonObject = jsonArray.getJSONObject(i);
dishes model = new dishes();
model.setId(jsonObject.getInt("id"));
model.setIntro(jsonObject.getString("intro"));
model.setImg_url(jsonObject.getString("img_url"));
model.setTitle(jsonObject.getString("title"));
model.setPrice(jsonObject.getDouble("price"));
list.add(model);
}
} catch (JSONException e) {
e.printStackTrace();
}
} else {
toastUtil.show("没有数据");
}
adapter = new DishesAdapter(DishesListActivity.this, list);
listview1.setAdapter(adapter);
}
}
private class loadAsyncTask extends AsyncTask<String, Integer, String> {
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(PlaceOrderActivity.this, "提示", "获取中,请稍后..");
}
@Override
protected String params) {
String urlString = AppConstant.getUrl(getApplicationContext()) + "ServletService?Action=getOneRow";
urlString = urlString + "&Table=seats";
String json = httpHelper.HttpRequest(urlString);
return json;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
dialog.dismiss();
if (im().length() > 0) {
try {
jsonArray = new JSONArray(result);
LinearLayout ll = null;
for (int i = 0; i < jsonArray.length(); i++) {
jsonObject = jsonArray.getJSONObject(i);
if (i % 6 == 0) {
ll = new LinearLayout(PlaceOrderActivity.this);
ll.setOrientation(LinearLayout.HORIZONTAL);
ll.setGravity(Gravity.CENTER);
}
final ImageView imageView = new ImageView(PlaceOrderActivity.this);
imageView.setPadding(5, 5, 5, 5);
imageView.setTag(jsonObject.getInt("id") + "," + jsonObject.getInt("state") + ",0");
if (jsonObject.getInt("state") == 0) {
imageView.setImageResource(R.drawable.seat_unavailable);
} else {
imageView.setImageResource(R.drawable.seat_sel);
}
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String tag = v.getTag().toString();
String id = tag.split(",")[0];
String state = tag.split(",")[1];// 是否被选择
String sel = tag.split(",")[2];// 是否选中
if ("1".equals(state)) {
toastUtil.show("该座位已被选");
} else {
if ("1".equals(sel)) {
imageView.setImageResource(R.drawable.seat_unavailable);
imageView.setTag(id + "," + state + "," + "0");
hashMap.remove(Integer.valueOf(id));
setSel();
} else {
imageView.setImageResource(R.drawable.seat_selected);
imageView.setTag(id + "," + state + "," + "1");
hashMap.put(Integer.valueOf(id), Integer.valueOf(id));
setSel();
}
安卓课程设计源代码 }
}
});
ll.addView(imageView);
if (i % 6 == 0) {
llSeat.addView(ll);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
private class loadAsyncTask extends AsyncTask<String, Integer, String> {
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(MyOrdersListActivity.this, "提示", "获取中..");
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论