0
我只是一個初學者,使用編程語言android,我的項目從互聯網獲得,現在我得到的代碼顯示值爲MySQL
,使用RatingBar
發送值ratingbar
本身,我需要幫助如何使用它!ANDROID - ListView中的RatingBar示例將數據發送到MySQL所需的示例
有人可以解釋如何在listview
中使用ratingbar
??
我想創建這樣一個佈局:
|------------------|
| 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);
我的問題是我怎麼知道哪個的RatingBar列表是onTouch
?
併發送從listview
填充到服務器的任何評級欄值?
我一直試圖找到從互聯網上的任何教程,但教程是如此scrimpy