Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误的资源值?_Java_Android_Android Resources - Fatal编程技术网

Java 错误的资源值?

Java 错误的资源值?,java,android,android-resources,Java,Android,Android Resources,我正在一个android项目中工作,在一个库项目中创建了一个JAR文件 JAR文件中drawable文件夹中的图像顺序如下: image1 image2 现在在我的应用程序中,drawable文件夹具有以下图像序列: image3 image4 image1 现在,如果我想从库代码中选择drawable作为R.drwable.image1,它会从我的应用程序drawable文件夹中选择image3并显示它 如果image1位于image3上方,则会正确显示它的图像 我不知道为什么我会遇到订购

我正在一个android项目中工作,在一个库项目中创建了一个JAR文件

JAR文件中drawable文件夹中的图像顺序如下:

image1
image2
现在在我的应用程序中,drawable文件夹具有以下图像序列:

image3
image4
image1
现在,如果我想从库代码中选择drawable作为R.drwable.image1,它会从我的应用程序drawable文件夹中选择image3并显示它

如果image1位于image3上方,则会正确显示它的图像


我不知道为什么我会遇到订购的问题。我使用的是android SDK第18版。我使用eclipse中的“FatJar”插件创建了一个JAR。

我不确定为什么它会选择image3,即使您选择了
R.drawable.image1

但是试试这个

R.drwable.image1[1]
更新:

NotificationCompat.Builder mBuilder =
        new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.icon)
        .setContentTitle("My notification")
        .setContentText("Hello World!");
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, ResultActivity.class);

// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(ResultActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
        stackBuilder.getPendingIntent(
            0,
            PendingIntent.FLAG_UPDATE_CURRENT
        );
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(mId, mBuilder.build());

你能贴一张复制品吗?然后我们可能会发现错误…您如何调用drawable?我将drawable称为R.drawable.icon。您应该使用librarypackagename.R.drawable.icon引用库中的图像drawableproject@kjurkovic:它是一个JAR文件。您确定它将显示来自JAR的图像。它将拾取图像3。但若在库JAR中,若image1位于第二位置,并且在应用程序中,若image1位于第二位置,则显示正确。我很惊讶为什么它会以有序的方式映射图像。我以以下方式拾取通知的图像:通知通知=新通知(R.drawable.icon,tickerText,when);此处选择的R.drawable.icon错误。因此,您的可绘制文件夹中有一个名为icon的文件?是的,库中的可绘制文件夹中有icon,应用程序中的可绘制文件夹中也有icon。我不确定原因。。查看我的更新答案,并尝试比您的方法更好的方法。