3

I have a weird issue. I have a simple alertDialog I passed it an arguments but I see it blank except the icon.

this is the method:

public class ViewUtil {

//// some code...

public static void showMessagePopup(int titleResId, String message, Context context) {
    new AlertDialog.Builder(context)
            .setTitle(context.getResources().getString(titleResId))
            .setMessage(message)
            .setIcon(R.mipmap.ic_launcher)
            .show();
}

And here I call it

public class RedesignNewDriverPopup extends Dialog {
/// some code...

 new PrepareRestApiTask<>(new PrepareRestApiTask.restApiCaller<String>() {
                @Override
                public Call<RestResponse<String>> onRestApiReadyBackgroundRun(String hashedToken,
                                                                              SmartbusClient client) {
                    return client.update_driver(driver.id, req, hashedToken);
                }

                @Override
                public void onEverythingFinishedUIThreadRun(String theData) {
                    updateCallback.afterDriverUpdate();
                    ViewUtil.showMessagePopup(R.string.new_driver, getContext().getResources().getString(R.string.driver_created), getContext());
                    dismiss();
                }

                @Override
                public void onError(Response<RestResponse<String>> response) {
                    ViewUtil.showMessagePopup(R.string.new_driver, getContext().getResources().getString(R.string.login_error), getContext());
                    dismiss();
                }


            }).execute();

this is my theme:

 `<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/DrawerArrowToggle</item>
    <item name="android:actionBarStyle">@android:style/Widget.Holo.ActionBar</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
</style>`

As I said, I can see the icon but not the title or the message.

Thanks

Codey
  • 460
  • 1
  • 8
  • 23

1 Answers1

1

try this:

ViewUtil.showMessagePopup(activity_context.getResources().getString(R.string.new_driver), activity_context.getResources().getString(R.string.driver_created), activity_context);

pass the Activity context in your Dialog class and use it

Also in your :

    public static void showMessagePopup(String titleResId, String message, Context context) {
    new AlertDialog.Builder(context)
            .setTitle(titleResId)
            .setMessage(message)
            .setIcon(R.mipmap.ic_launcher)
            .show();
}

To pass context:

//in activity
MyDialogClass dialog=new MyDialogClass(this);

Now in your Dialog class use:

 Context activity_context;
MyDialogClass(Context context){
this.activity_context=context; //now use activity_context to show alertDialog
}
rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62