I am trying to make a custom dialog in my Library Project via XML.
Here is the XML File:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tenlogix" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="25dp" >
<Button
android:id="@+id/likeitb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/likeitd" />
<Button
android:id="@+id/dontlikeitb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/dontliked" />
<Button
android:id="@+id/notnowb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/notnowd" />
</LinearLayout>
</RelativeLayout>
In Simple Java Class I am creating Dialog Like this:
final 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.ratedialog);
Button LikeIt = (Button) mAct.findViewById(R.id.likeitb);
Button DontLikeIt = (Button) mAct.findViewById(R.id.dontlikeitb);
Button NotNow = (Button) mAct.findViewById(R.id.notnowb);
LikeIt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String url = "market://details?id="+mAct.getPackageName();
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
mAct.startActivity(i);
mAct.finish();
}
});
If I don't set click listener of LikeIt button the dialog is displayed, but when I try to set a click listener on it. It's giving me a null pointer exception.
I am unable to find a solution for this. The LikeIt button is null when I try to access it.
I dont have any same name resources. Please help.
The reference mAct is the activity from another project in which library project is being used.
Looking forward for a positive and quick response.
Thanks.