ANDROID - ListView示例中的RatingBar,用于将数据发送到MySQL

时间:2016-11-27 13:39:29

标签: android mysql listview ratingbar

我只是编程语言android的初学者,我的项目是从互联网上获得的,现在我得到的代码显示来自MySQL的值并使用RatingBar发送值{{1本身,我需要帮助如何使用它!

有人可以解释如何在ratingbar ??

中使用ratingbar

我要创建一个这样的布局:

listview

这是我尝试在|------------------| | TextView | ---> Questionare question obtained from server (id 1) | * * * * * | ---> Rating Bar the value |------------------| | TextView | ---> Questionare question obtained from server (id 2) | * * * * * | ---> Rating Bar the value |------------------| | TextView | ---> Questionare question obtained from server (id 3) | * * * * * | ---> Rating Bar the value |__________________|

中展示ratingbar的一些代码

listview

AsyncTask doInBackground

我的问题是我如何知道列表中的哪个评级栏是HttpHandler sh = new HttpHandler(); String url = "http://****.com/send_data.php"; String jsonStr = sh.makeServiceCall(url); Log.e(TAG, "Response from url: " + jsonStr); if (jsonStr != null) { try { JSONArray jsonObj = new JSONArray(jsonStr); for (int i = 0; i < jsonObj.length(); i++) { JSONObject c = jsonObj.getJSONObject(i); String id = c.getString("id"); String ask = c.getString("ask"); HashMap<String, String> pertanyaans = new HashMap<>(); pertanyaans.put("id", id); pertanyaans.put("ask", ask); contactList.add(pertanyaans); } } catch (final JSONException e) { Log.e(TAG, "Json parsing error: " + e.getMessage()); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), "Json parsing error: " + e.getMessage(), Toast.LENGTH_LONG) .show(); } }); } } else { Log.e(TAG, "Couldn't get json from server."); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), "Couldn't get json from server. Check LogCat for possible errors!", Toast.LENGTH_LONG) .show(); } }); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result) if (pDialog.isShowing()) pDialog.dismiss(); ListAdapter adapter = new SimpleAdapter( Pertanyaan.this, contactList, R.layout.list_pertanyaan, new String[]{"ask", "id"}, new int[]{R.id.ask, R.id.txtid}); lv.setAdapter(adapter);

并将从onTouch填充的任何评级栏值发送到服务器?

  

我试图从互联网上找到任何教程,但教程非常简洁

1 个答案:

答案 0 :(得分:0)

创建由BaseAdapter扩展的类,然后在getView()方法中识别评级栏,然后你必须为评级栏设置触摸监听器。