Resources$NotFoundException: Resource ID #0x0 in AlertDialog

Although I have searched various questions/answers on both Stack Overflow and other sites, I have not found a solution to my problem.

I have a RecyclerView, and in its adapter, I have created something similar to a OnLongClickListener, which I am calling a OnEntryLongClickListener to avoid confusion.

  • CursorWindowAllocationException in standard ORMLite method
  • Actions of Actors in libgdx
  • can Dagger be used to perform injection on a Content Provider?
  • VideoView flickering issue
  • How to configure Tesseract in Eclipse for Android development?
  • Some questions about OAuth and Android
  • I am using an AlertDialog to display a dialog with list items for different actions. However I am getting the following error:

    E/AndroidRuntime: android.content.res.Resources$NotFoundException: Resource ID #0x0
    …at android.content.res.Resources.getValue(
    …at android.content.res.Resources.loadXmlResourceParser(
    …at android.content.res.Resources.getLayout(
    …at android.view.LayoutInflater.inflate(
    …at android.view.LayoutInflater.inflate(
    …at com.mycompany.myapp.ThisActivity$2.onEntryLongClick(
    …at com.mycompany.myapp.adapter.RVAdapter$RVViewHolder.onLongClick(
    …at android.view.View.performLongClick(

    Below is the relevant code I am using:

    adapter.setOnEntryLongClickListener(new RVAdapter.OnEntryLongClickListener() {
        public void onEntryLongClick(View view, int position) {
            final MiniEntry thisEntry = entryList.get(position);
            AlertDialog.Builder builder = new AlertDialog.Builder(getBaseContext());
            builder.setItems(R.array.quickActions, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // Other code here
            AlertDialog alert = builder.create(); // The error log points to this line

    As well as the XML I am using for the array:

    <string-array name="quickActions">
        <item>Add to Favourites</item>
        <item>More information</item>

    I’m not sure if it matters, but I am importing the AlertDialog from (from the v7 Support Library)

    Related posts:

    Changing position of the Dialog on screen android
    Which API version for Android 2.3.6?
    How is Google verifying SHA1 and package name in API calls?
    Detect shaking of device in left or right direction in android?
    How to store multiple datatypes in an array?
    Native bridge between Python and Dalvik or AAF
  • iOS Google Analytics Custom Dimensions
  • Cannot resize linear layout children in android react native module
  • Android Saving created bitmap to directory on sd card
  • Layout buttons so each divides up the space equally
  • Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova
  • Hide RecyclerView scrollbar
  • 2 Solutions collect form web for “Resources$NotFoundException: Resource ID #0x0 in AlertDialog”

    Change getBaseContext() in the AlertDialog.Builder instantiation to the current Activity instance. For example:

    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

    An AlertDialog requires certain resources whose values are provided by the themes and styles attached to the Context it uses. The Context returned by getBaseContext() doesn’t have those attached, but the Activity does. Indeed, whenever a Context is needed for a UI component – e.g., Dialogs, Views, Adapters, etc. – the current Activity is usually what you want to use.

    Try putting an style for your Dialog that extends Theme.AppCompat.Light.Dialog.Alert

    <style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert" />

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),;

    This works for me.


    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.