從服務器獲得響應後,我在我的整數數組中存儲點,我試圖在我的水平滾動視圖中添加該數組,但它給了我循環中的錯誤,以下是我的代碼誰能幫助?謝謝提前近此行不能解決方法get(int)
錯誤
tv.setText(points.get(i));
JAVA
protected ArrayList<HashMap<String, String>> doInBackground(
String... args) {
ServiceHandler sh = new ServiceHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(PLACE_URL, ServiceHandler.GET);
Log.d("Response: ", "> " + jsonStr);
if (jsonStr != null) {
try {
placejsonObj = new JSONArray(jsonStr);
// state_list = jsonObj.getJSONArray(COUNTRY_LIST);
// looping through All Contacts
jobject = placejsonObj.getJSONObject(0);
msgs=jobject.getString("user_status");
pointsarray=placejsonObj.getJSONArray(1);
// points=pointsarray.getString("point");
System.out.println("Kya yar" + "Failure"+pointsarray);
points = new int[pointsarray.length()];
for(int m=0; m<pointsarray.length(); m++) {
points[m] = pointsarray.getJSONObject(m).getInt("point");
}
System.out.println("array contains" + points.length + " elements");
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return null;
}
protected void onPostExecute(ArrayList<HashMap<String, String>> result) {
super.onPostExecute(result);
pDialog.dismiss();
for (int i = 0; i < points.length; i++) {
tv = new TextView(getActivity());
tv.setText(points[i]+",");
tv.setTag(points[i]);
yourLayout.addView(tv);
}
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int point = (int) view.getTag();
Toast.makeText(getActivity(),point,Toast.LENGTH_SHORT).show();
}
});
}
}
感謝它workd ....這樣的sillly錯誤 – albert