I am designing (trying to learn) a simple widget for Android. I have:
public class NewAppWidget extends AppWidgetProvider {
Inside that class, I have the simple code:
public double angle(Calendar calendarDate) {
//Earth rotation;
int day = calendarDate.get(Calendar.DAY_OF_YEAR);
int angle;
angle = (day / 365) * 360;
return angle;
}
I then want to select an image and rotate it by that angle in ImageView, which totally does not work ...
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
// Construct the RemoteViews object
ImageView image = (ImageView) findViewById(R.layout.new_app_widget);
image.setImageResource(R.drawable.moon10);
image.setRotation(angle);
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, new_app_widget);
}
There are probably several mistakes in there - I am a beginner.
The three errors highlighted by Android studio are:
- findViewById in red (cannot resolve method)
- angle in red (cannot resolve symbol angle)
- new_app_widget in last line in red (cannot resolve symbol)
Thanks for your help and have a good day.
JY