ورود

View Full Version : نشون ندادن داده های سرور توی لیست ویو



mohammadreza761
چهارشنبه 14 اسفند 1392, 22:57 عصر
سلام به دوستان برنامه نویس اندرویدی.
چندی پیش درخواست کمک برای نشون دادن داده ها توی لیست ویوو با استفاده از Async Task فرستادم که جوابی نشنیدم .
اما اون کد رو نوشتم و بدون خطا اجرا شد اما هیچی توی لیست ویو نشون نمیده. دوستان اگه کسی میدونه چرا این خطا رو میده بهم بگه لطفا خیلی ضروریه . واسه پروژست.

این logcat هست :

03-05 19:54:42.729: W/EGL_emulation(1704): eglSurfaceAttrib not implemented
03-05 19:54:42.937: D/OpenGLRenderer(1704): TextureCache::get: create texture(0xb957bfc0): name, size, mSize = 26, 1048576, 1084288
03-05 19:54:48.349: D/OpenGLRenderer(1704): TextureCache::get: create texture(0xb9590258): name, size, mSize = 30, 7488, 1091776
03-05 19:54:48.965: I/Choreographer(1704): Skipped 32 frames! The application may be doing too much work on its main thread.
03-05 19:54:49.341: W/EGL_emulation(1704): eglSurfaceAttrib not implemented
03-05 19:54:49.469: W/EGL_emulation(1704): eglSurfaceAttrib not implemented
03-05 19:54:49.613: D/OpenGLRenderer(1704): TextureCache::get: create texture(0xb9594e58): name, size, mSize = 34, 34560, 1126336
03-05 19:54:49.645: D/OpenGLRenderer(1704): TextureCache::get: create texture(0xb9572670): name, size, mSize = 35, 20736, 1147072
03-05 19:54:49.681: D/OpenGLRenderer(1704): TextureCache::get: create texture(0xb9573f40): name, size, mSize = 36, 20736, 1167808
03-05 19:54:50.077: I/Choreographer(1704): Skipped 33 frames! The application may be doing too much work on its main thread.
03-05 19:54:50.321: D/All Post(1704): {"posts":[{"writer":"mohammadreza","text":"this is a test","title":"mozoo1","pid":"1"}],"success":1}



اینم کد های صفحه گرفتن پست های هست(get all post):

public class AllPost extends Activity {
ListView lv;
private ProgressDialog pDialog;
JSONParser jParser=new JSONParser();
ArrayList<HashMap<String, String>> postlist;
private static final String url_all_post="http://192.168.56.1/androidhivemysql/getAllPost.php";
private static final String TAG_SUCCESS="success";
private static final String TAG_POSTS="posts";
private static final String TAG_PID="pid";
private static final String TAG_TITLE="title";
JSONArray posts=null;

protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.all_post);
lv=(ListView)findViewById(R.id.listView1);
postlist=new ArrayList<HashMap<String,String>>();
new LoadAllPosts().execute();
ListView lv=getListView();


}
private ListView getListView() {
// TODO Auto-generated method stub
return null;
}
class LoadAllPosts extends AsyncTask<String, String, String>{
@Override
protected String doInBackground(String... arg0) {
List<NameValuePair> params=new ArrayList<NameValuePair>();
JSONObject json=jParser.makeHttpRequest(url_all_post, "GET", params);
Log.d("All Post",json.toString());
try{
int success=json.getInt(TAG_SUCCESS);
if(success==1){
posts=json.getJSONArray(TAG_POSTS);
for(int i=0;i<posts.length();i++){
JSONObject c=posts.getJSONObject(i);
String id=c.getString(TAG_PID);
String title=c.getString(TAG_TITLE);
HashMap<String, String> map=new HashMap<String, String>();
map.put(TAG_PID, id);
map.put(TAG_TITLE, title);
postlist.add(map);
}
}else{
Intent i=new Intent(getApplicationContext(),MainActivity.class) ;
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
}catch(JSONException e){
e.printStackTrace();
}


return null;
}//end of do in background
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(AllPost.this);
pDialog.setMessage("بارگذاری اخبار . لطفا منتظر بمانید...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}//end of preexcute
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
pDialog.dismiss();
runOnUiThread( new Runnable() {
public void run() {
ListAdapter adapter=new SimpleAdapter(AllPost.this, postlist, R.layout.list_post, new String[]{TAG_PID,TAG_TITLE},new int[]{R.id.pid,R.id.title});
setListAdapter(adapter);
}
});

}//end of onPostExecute
protected void setListAdapter(ListAdapter adapter) {
// TODO Auto-generated method stub

}
}//end of Async Task

}