android - How to display data retrieved from the SOAP ListView? -
welcome have problem addition of listview data retrieved soap
. when create listview
pops following error:
04-06 00:12:47.852: w / dalvikvm (4092): threadid = 1: thread exiting uncaught exception (group = 0x409c01f8) 04-06 00:12:48.123: e /androidruntime (4092): fatal exception: main 04-06 00:12:48.123: e /androidruntime (4092): android.content.res.resources $notfoundexception: resource id # 0x7f08000c type # 0x12 not valid
not understand happening.
please solve problem , explain happening in error gets called.
package com.example.pit_testy; import java.util.arraylist; import java.util.hashmap; import java.util.map; import org.json.jsonobject; import android.os.bundle; import android.os.countdowntimer; import android.app.activity; import android.content.intent; import android.util.log; import android.view.menu; import android.view.view; import android.widget.arrayadapter; import android.widget.button; import android.widget.listview; import android.widget.textview; import com.example.pit_testy.r; import com.example.pit_testy.soap.asynctaskmanager; import com.example.pit_testy.soap.getsoaptasktest; import com.example.pit_testy.soap.onasynctaskcompletelistener; import com.example.pit_testy.soap.pittestymsg; import com.example.library.userfunctions; public class testyactivity extends activity { userfunctions userfunctions; private button buttonwynik, buttonstarttest; private countdowntimer testtotalclock; private long initialtotaltime = 300000; private long intervalsecondtime = 1000; private asynctaskmanager taskmenager; private textview textclock, textquestion; private listview listquestions; private arrayadapter<string> listadapter; private arraylist<string> arraylistquestions; private string categoryid = "0"; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_testy); taskmenager = new asynctaskmanager(this); textclock = (textview)findviewbyid(r.id.texttimer); textclock.settext("czas start!"); textquestion = (textview)findviewbyid(r.id.texttrescpytania); textquestion.settext("treść pytania"); testtotalclock = new countdowntimer(initialtotaltime, intervalsecondtime) { @override public void ontick(long millisuntilfinished) { integer milisec = new integer(new double(millisuntilfinished).intvalue()); integer cdsecs = milisec / 1000; integer minutes = (cdsecs % 3600) / 60; integer seconds = (cdsecs % 3600) % 60; textclock.settext(minutes.tostring()+":"+seconds.tostring()); } @override public void onfinish() { textclock.settext("koniec czasu!"); userfunctions.logoutuser(getapplicationcontext()); intent nextview = new intent(getapplicationcontext(), wynikactivity.class); nextview.addflags(intent.flag_activity_clear_top); startactivity(nextview); } }; loadtest(categoryid); // wybór kategorji buttonstarttest = (button)findviewbyid(r.id.buttonstart); buttonstarttest.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { testtotalclock.start(); textquestion.settext("jak masz na imie?"); } }); buttonwynik = (button)findviewbyid(r.id.buttonwynik); userfunctions = new userfunctions(); buttonwynik.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { testtotalclock.cancel(); userfunctions.logoutuser(getapplicationcontext()); intent nextview = new intent(getapplicationcontext(), wynikactivity.class); nextview.addflags(intent.flag_activity_clear_top); startactivity(nextview); } }); testtotalclock.cancel(); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.testy, menu); return true; } private void loadtest(string category) { map<string, string> map = new hashmap<string, string>(); map.put("aid", "1"); map.put("categories", category); getsoaptasktest task = new getsoaptasktest(); taskmenager.executetask(task, getsoaptasktest.createrequest("getcategories", new jsonobject(map).tostring()), "wykonano executetask", new onasynctaskcompletelistener<pittestymsg>() { arraylist<string> arraylistquestions = new arraylist<string>(); @override public void ontaskcompletesuccess(pittestymsg result) { if (result.errorcode == 0){ (map <string, string> var : result.data) { log.i("soapcategories", "testy pobrane = " + var.get("name")); arraylistquestions.add(var.get("name")); } taskmenager.onpostexecute(arraylistquestions); intent maintest = new intent(getapplicationcontext(), testyactivity.class); startactivity(maintest); }else{ log.i("soapcategories", "testy niepobrane"); } } @override public void ontaskfailed(exception cause) { log.e("soap", cause.getmessage(), cause); } }); } } public final class asynctaskmanager implements iprogresstracker { private final progressdialog progressdialog; private listview listquestions; private arrayadapter<string> listadapter; private context mycontext; public asynctaskmanager(context context) { mycontext = context; this.progressdialog = new progressdialog(context); this.progressdialog.setcancelable(false); this.progressdialog.setprogressstyle(progressdialog.style_spinner); } /** * executes task in background thread, while displaying busy dialog (non cancellable). * * @param task * {@link abstractprogressableasynctask} * @param request * request background task * @param progresslabel * label displayed when progress dialog being displayed. * @param ontaskcompletedlistener * {@link onasynctaskcompletelistener} notified once task completed. */ public <t, p> void executetask(abstractprogressableasynctask<p, t> task, p request, charsequence progresslabel, onasynctaskcompletelistener<t> ontaskcompletedlistener) { this.progressdialog.setmessage(progresslabel); task.setontaskcompletionlistener(ontaskcompletedlistener); //task.setprogresstracker(this); task.execute(request); } // ------------------------------------------------------------------------ // progress handlers // ------------------------------------------------------------------------ @override public void onstartprogress() { progressdialog.show(); } @override public void onstopprogress() { progressdialog.dismiss(); } @override public void onpostexecute(arraylist<string> list){ listadapter = new arrayadapter<string>(mycontext, r.id.listapytan, list); listquestions = (listview)((activity) mycontext).findviewbyid(r.id.listapytan); listquestions.setadapter(listadapter); log.i("listview", "lista wyswietlona"); } }
you should use arrayadapter in following way
new arrayadapter<string>(mycontext, android.r.layout.simple_list_item_1, list)
instead of
new arrayadapter<string>(mycontext, r.id.listapytan, list)
Comments
Post a Comment