资源不包含资源编号的包

时间:2011-02-24 05:55:27

标签: java android android-widget

我正在尝试编写一个简单的app小部件,它具有一个配置,并使用AlarmManager以更快的速度更新自己(这是一个时钟,所以它需要相当当前)。我按照Google的示例来了解如何执行此操作their documentation.

现在发生了什么,时钟使用各种图像来显示它是什么时间以及何时在模拟器上安装文件我得到以下错误:

  

资源不包含资源编号为0x7f0700e5的包

它说大约有15种不同的东西在drawables,drawables-hdpi和strings之间变化。起初我以为this solution可能会解决我的问题,但我现在几乎完全遵循Google的代码。

以下是配置文件的设置方式:

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);

    setResult(RESULT_CANCELED);

    setContentView(R.layout.config);

    configOkButton = (Button)findViewById(R.id.btnConfOk);
    configOkButton.setOnClickListener(btnConfOkOnClickListener);

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();

    Log.d(TAG, "onCreate-if(extras !- null)");
    if(extras != null) {
        mAppWidgetId = extras.getInt(
                AppWidgetManager.EXTRA_APPWIDGET_ID,
                AppWidgetManager.INVALID_APPWIDGET_ID);
        Log.d(TAG, "onCreate-mAppWidgetId = " + String.valueOf(mAppWidgetId));
    }

    Log.d(TAG, "onCreate-if(mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID");
    if(mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID){
        Log.d(TAG, "onCreate-Invalid AppWidget ID");
        finish();
    }
}

private Button.OnClickListener btnConfOkOnClickListener = new Button.OnClickListener() {

    public void onClick(View v) {
        Log.d(TAG, "onClick");
        final Context context = WordTimeWidgetConfig.this;

        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        WordTimeWidget.updateWordTimeWidget(context, appWidgetManager, mAppWidgetId);

        // This puts the clock on a schedule to keep it updated with the current time
        Log.d(TAG, "onClick-Creating the AlarmManager");
        Intent intent = new Intent(WordTimeBroadcastReceiver.WORDTIME_UPDATE_INTENT);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(WordTimeWidgetConfig.this, RESULT_OK, intent, 0);
        AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.add(Calendar.SECOND, 10);
        alarmManager.setRepeating(AlarmManager.RTC, calendar.getTimeInMillis(), WordTimeWidget.CLOCK_UPDATE_RATE, pendingIntent);

        Log.d(TAG, "onClick-Saving the AlarmManager");
        WordTimeWidget.saveAlarmManager(alarmManager, pendingIntent);

        Log.d(TAG, "onClick-Creating the Intent and finishing the method");
        Intent resultValue = new Intent();
        resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
        setResult(RESULT_OK, resultValue);
        finish();
    }
};

这看起来非常简单。可能发生的唯一真正奇怪的事情是我在updateWordTimeWidget(context, appWidgetManager, mAppWidgetId);调用中传递了Widget配置上下文。

那么我做错了什么?任何帮助,将不胜感激。如果需要,我可以提供更多代码。

0 个答案:

没有答案