android - Null Pointer Exception Handling Button from XML in Library Project -
I am trying to create a custom dialog in my library project via XML I
Here is the XML file:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: background = "@drawable / tanlaxics" & gt; & Lt; LinearLayout Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_algir parentbottom = "true" android: layout_marginLeft = "25dp" & gt; & Lt; Button Android: id = "@ + id / likeitb" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: background = "@dictrum / / likeitd" /> gt; & Lt; Android: id = "@ + id / dontlikeitb" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: background = "@drawable / doplocked" /> & Lt; Button Android: id = "@ + id / notnowb" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: background = "@drawable / nooday" /> & Lt; / LinearLayout & gt; & Lt; / RelativeLayout & gt;
In simple Java class, I am creating a dialog like this:
last dialog feed_back_dialog = new dialog (mact); Feed_back_dialog.getWindow () SetBackgroundDrawable (New ColorDrawable (0)); Feed_back_dialog.setCancelable (true); Feed_back_dialog.requestWindowFeature (Window.FEATURE_NO_TITLE); Feed_back_dialog.setContentView (R.layout.retialog); Like button = (button) mAct.findViewById (R.id.likeitb); Button DontLikeIt = (Button) mAct.findViewById (R.id.dontlikeitb); Button NotNow = (Button) mAct.findViewById (R.id.notnowb); LikeToSetOnClickListener (see newOnClickListener) {@Override Public Zero (click V) {String URL = "Market: // Description? Id =" + mAct.getPackageName (); Intent I = new intent (Intent.ACTION_VIEW); I.setData (Uri.parse (url)); MAct.startActivity (i); MAct.finish ();}});
If I have not set the listener on as the
button has been displayed, but when I try to set a click listener on it I'm giving it a null pointer exception, I am unable to find a solution for this. When I try to access it,
like this
button is redundant. I have no such name resource. Please help.
Reference It should be like this mAct
is the activity of another project in which the Library Project is being used. Looking forward to a positive and quick response, thanks. Just replace mAct
in these lines of code with
. Feed_back_dialog
like feed_back_dialog
your current layout like button = (button) mAct.findViewById (R.id.likeitb); Button DontLikeIt = (Button) mAct.findViewById (R.id.dontlikeitb); Button NotNow = (Button) mAct.findViewById (R.id.notnowb);
like button = (button) feed_back_dialog .findViewById (R.id.likeitb); Button DontLikeIt = (Button) feed_back_dialog.findViewById (R.id.dontlikeitb); Button NotNow = (Button) feed_back_dialog.findViewById (R.id.notnowb);
Comments
Post a Comment