android - OnClick() on buttons not working after I do something and return back to button's activity -
i have debugged , found flow of control never reaches onclick()
method in main activity after come activity launched main activity.
suspecting gotta 'paused' or 'resumed' state.
in other words, main activity a. , activity launched b. so, launch , work on b. , when return (using hardware button 'back') onclick
function doesnt seem called.
for privacy purpose have removed code displayed below give error if compiled, in actual code activity b , listviews call run fine .
please help! :)
my code:
import java.io.serializable; import java.util.arraylist; import org.json.jsonobject; import android.os.bundle; import android.app.activity; import android.content.intent; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; public class main extends activity implements serializable, onclicklistener { // fetch data in form of string url public string internetdata; public static arraylist<string> list; public static boolean hasranonce; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); initialize(); // begin asynctask doinbackground requestdata(); } private void initialize() { hasranonce = boolean.false; list = new arraylist<string>(); } private void requestdata() { //string url, removed here getmethodex requestobject = new getmethodex(); requestobject.setactivity(this); requestobject.execute(string); } // function called onpostexecute of getmethodex public void buildnodes() { try { // create json objects rootnode = rootnode.createnode(jobject); passlist.add(rootnode); } catch (exception e) { e.printstacktrace(); } } protected void startlist() { // start new activity publishing results list intent mylist = new intent(this, list.class); mylist.putextra("passlist", passlist); hasranonce = boolean.true; startactivity(mylist); }
///##where facing problem possibly
@override public void onclick(view v) { switch (v.getid()) { case r.id.display: startlist(); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.activity_menu, menu); return true; } }
try code button.setonclicklistener(new onclicklistener() { public void onclick(view v) { // todo auto-generated method stub intent mylist = new intent(this, list.class); mylist.putextra("passlist", passlist); hasranonce = boolean.true; startactivity(mylist); } });
Comments
Post a Comment