java - Activity is not starting -



java - Activity is not starting -

please have @ next code

form.java

my main activity form.java. within that, have alertdialog. when user clicks on "yes" button, next class called

private class positivedialogbtnaction implements dialoginterface.onclicklistener { public positivedialogbtnaction() { } @override public void onclick(dialoginterface arg0, int arg1) { // todo auto-generated method stub //toast.maketext(getapplicationcontext(), databaseconnector.getstreetaddress(selectedbranch), toast.length_long).show(); dialog dialog = new dialog(context); dialog.setcontentview(r.layout.activity_call_dialog); dialog.settitle("select phone number"); dialog.show(); } }

following xml file , java class, beingness set dialog within positivedialogbtnaction class mentioned above.

activity_call_dialog

<textview android:id="@+id/callnumber1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_centervertical="true" android:text="" /> <textview android:id="@+id/callnumber2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_centervertical="true" android:text="" />

calldialog.java

import android.os.bundle; import android.app.activity; import android.view.menu; import android.widget.textview; import android.widget.toast; public class calldialog extends activity { private databaseconnector database = databasehandler.getinstance(); private textview ph1,ph2; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_call_dialog); toast.maketext(this, "activity running", toast.length_long).show(); //string selectedbranch = form.selectedbranch; //ph1 = (textview)findviewbyid(r.id.callnumber1); //ph2 = (textview)findviewbyid(r.id.callnumber2); //ph1.settext(database.getphonenumber1(selectedbranch)); //ph2.settext(database.getphonenumber2(selectedbranch)); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.activity_call_dialog, menu); homecoming true; } }

but, when positivedialogbtnaction fired, toast mentioned in calldialog.java never fired. seems not dealing calldialog.java. because of that, unable set values text fields in activity_call_dialog.xml well. have commented out lines.

why java file bundled activity not getting called? please help!

for creating alert dialog should utilize alertdialog.builder. has beautiful fluent interface makes easy handle dialogs. example:

new alertdialog.builder(this) .setmessage("someone calling you") .setpositivebutton("positive", new onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { startactivity(new intent("com.example.calldialogactivity")); }}) .create() .show();

in order start new activity within click listener, phone call startactivity() action registered in androidmanifest.xml calldialog (i suggest rename calldialogactivity). anyway, should determine utilize dialogs or activities. have handled accordingly.

java android eclipse android-activity android-dialog

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -