안녕하세요
PullToRefresh 실행을 하니 11개의 리스트뷰가 내용이 있는데 0개로
즉 전혀 읽어 오지를 못하는듯합니다.
아래 코딩을 보시고 조언이나 방법좀 알려주세요
new XmlAsyncTask(context).execute(); 아무래도 이부분인듯 한데 내부 context를 사용하면 빨간줄 나오고 ㅠ
제가 초보라 완전 감을 잡지를 못하겠습니다. 어케해야할지 ㅠㅠ
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.syaku_main);
// XML 데이터 호출
XmlAsyncTask xml = new XmlAsyncTask(this);
String url = "http://www*****/android/freetalk/odtproduct.php";
xml.execute(url);
mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.list_view);
mPullRefreshListView .setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
// Do work to refresh the list here.
new XmlAsyncTask(context).execute();
}
});
}//onCreate
// AsyncTask 스레드
class XmlAsyncTask extends AsyncTask< String, Void , ArrayList<SparseArray<String>> > implements OnItemClickListener{
Context context;
ArrayList<XmlBean> list_item;
OnRefreshListener onRefreshListener;
public XmlAsyncTask(Context context) {
this.context = context;
}
@Override
protected ArrayList<SparseArray<String>> doInBackground(String... params) {
ArrayList<SparseArray<String>> list = new ArrayList<SparseArray<String>>();
try {
Thread.sleep(1000);
String url = params[0];
HttpConnection http = new HttpConnection(url);
InputStream input_stream = http.getInputStream();
Xml2Object xml = new Xml2Object(input_stream);
list = xml.list("item");
} catch (Exception e) {
Log.e("GET ERROR",e.toString());
}
return list;
}
@Override
protected void onPostExecute(ArrayList<SparseArray<String>> result) {
mPullRefreshListView.onRefreshComplete();
super.onPostExecute(result);
int count = result.size();
Log.d("ArrayList count",""+count);
TextView tv = (TextView) findViewById(R.id.list_count);
tv.setText(""+count);
list_item = new ArrayList<XmlBean>();