java - Alert Dialog (List) custom rows for items -


i trying popup list backed string array, using following code:

public void gamedialog(activity activity) {            textview title = new textview(activity);         title.settext("click number make call");         title.setbackgroundcolor(color.black);         title.setpadding(10, 10, 10, 10);         title.setgravity(gravity.center);         title.settextcolor(color.white);         title.settextsize(20);           alertdialog.builder builder = new alertdialog.builder(activity);         builder.setcustomtitle(title);         //builder.seticon(r.drawable.alert_36);      //  builder.setmessage(""+arrayphones);          builder.setcancelable(false);         builder.setitems(arrayphones,new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialoginterface, int i) {                }          });          alertdialog alert = builder.show();           textview messagetext = (textview)alert.findviewbyid(android.r.id.message);         messagetext.setgravity(gravity.center);     //  messagetext.settextcolor(color.red);      } 

i null pointer when try set attributes messagetext. want customize rows of above list placing text in center , different font color. hints wrong?

here logcat:

01-31 20:55:06.328: e/inputeventreceiver(25240): exception dispatching input event. 01-31 20:55:06.328: e/messagequeue-jni(25240): exception in messagequeue callback: handlereceivecallback 01-31 20:55:06.339: e/messagequeue-jni(25240): java.lang.nullpointerexception 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ com.exa.birthdayrem.fragment1_3.showalert(fragment1_3.java:347) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ com.exa.birthdayrem.fragment1_3$1.ontouch(fragment1_3.java:189) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.view.dispatchtouchevent(view.java:7138) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2238) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1935) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:1938) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1392) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.app.activity.dispatchtouchevent(activity.java:2408) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:1886) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.view.dispatchpointerevent(view.java:7323) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewrootimpl.deliverpointerevent(viewrootimpl.java:3560) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewrootimpl.deliverinputevent(viewrootimpl.java:3490) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewrootimpl.doprocessinputevents(viewrootimpl.java:4637) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewrootimpl.enqueueinputevent(viewrootimpl.java:4597) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.viewrootimpl$windowinputeventreceiver.oninputevent(viewrootimpl.java:4749) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.view.inputeventreceiver.dispatchinputevent(inputeventreceiver.java:171) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.os.messagequeue.nativepollonce(native method) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.os.messagequeue.next(messagequeue.java:125) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.os.looper.loop(looper.java:140) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ android.app.activitythread.main(activitythread.java:5000) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ java.lang.reflect.method.invokenative(native method) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ java.lang.reflect.method.invoke(method.java:511) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:821) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:584) 01-31 20:55:06.339: e/messagequeue-jni(25240):  @ dalvik.system.nativestart.main(native method) 01-31 20:55:06.339: d/androidruntime(25240): shutting down vm 01-31 20:55:06.340: w/dalvikvm(25240): threadid=1: thread exiting uncaught exception (group=0x40f67908) 01-31 20:55:06.346: e/androidruntime(25240): fatal exception: main 01-31 20:55:06.346: e/androidruntime(25240): java.lang.nullpointerexception 01-31 20:55:06.346: e/androidruntime(25240):    @ com.exa.birthdayrem.fragment1_3.showalert(fragment1_3.java:347) 01-31 20:55:06.346: e/androidruntime(25240):    @ com.exa.birthdayrem.fragment1_3$1.ontouch(fragment1_3.java:189) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.view.dispatchtouchevent(view.java:7138) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2238) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1935) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2244) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:1907) 01-31 20:55:06.346: e/androidruntime(25240):    @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:1938) 01-31 20:55:06.346: e/androidruntime(25240):    @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1392) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.app.activity.dispatchtouchevent(activity.java:2408) 01-31 20:55:06.346: e/androidruntime(25240):    @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:1886) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.view.dispatchpointerevent(view.java:7323) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewrootimpl.deliverpointerevent(viewrootimpl.java:3560) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewrootimpl.deliverinputevent(viewrootimpl.java:3490) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewrootimpl.doprocessinputevents(viewrootimpl.java:4637) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewrootimpl.enqueueinputevent(viewrootimpl.java:4597) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.viewrootimpl$windowinputeventreceiver.oninputevent(viewrootimpl.java:4749) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.view.inputeventreceiver.dispatchinputevent(inputeventreceiver.java:171) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.os.messagequeue.nativepollonce(native method) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.os.messagequeue.next(messagequeue.java:125) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.os.looper.loop(looper.java:140) 01-31 20:55:06.346: e/androidruntime(25240):    @ android.app.activitythread.main(activitythread.java:5000) 01-31 20:55:06.346: e/androidruntime(25240):    @ java.lang.reflect.method.invokenative(native method) 01-31 20:55:06.346: e/androidruntime(25240):    @ java.lang.reflect.method.invoke(method.java:511) 01-31 20:55:06.346: e/androidruntime(25240):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:821) 01-31 20:55:06.346: e/androidruntime(25240):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:584) 01-31 20:55:06.346: e/androidruntime(25240):    @ dalvik.system.nativestart.main(native method) 

in code alertdialog has not initialized yet gives nullpointer.initialize alertdialog through create() method of builder. like:

 alertdialog alert = builder.create();  alert.show(); 

and have not used view here. in method parameter take 1 view activity , initialize view components through not through alert.

public void gamedialog(activity activity, view view) { textview tv = (textview) view.findviewbyid(r.id.message); } 

and pass parent layout holds textview through parameter.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -