Hi, I'm wondering how an app shows a specific image for the current date of the device. So if this is January 1, then the same image will be shown for that date, and if it is March 5, it shows the image of March 5.
Import android.content.BroadcastReceiver; Import android.content.Context; Import android.content.Intent; Import android.widget.RemoteViews; Public Category Widget Extensor Extender Expands Broadcast Receiver {Personal Static Int current image = 0; Int [] images = {R.drawable.j_1, R.drawable.j_2, R.drawable.j_3, R.drawable.j_4, R.drawable.j_5, R.drawable.j_6, R.drawable.j_7, R. Drawable.j_8, R.drawable.j_9, R.drawable.j_10, R.drawable.j_11, R.drawable.j_12, R.drawable.j_13, R.drawable.j_14, R.drawable.j_15, R.drawable J_l6, Rkdravblekj_l7, Rkdravblekj_l8, Rkdravblekj_l9, Rkdravblekj_20, Rkdravblekj_2l, Rkdravblekj_22, Rkdravblekj_23, Rkdravblekj_24, R.drawable.j_25, R.drawable.j_26, R.drawable.j_27, R.drawable.j_28, R.drawable.j_29, R.drawable.j_30, R.drawable.j_31, R.drawable.f_1, R. Drawable.f_2, R.drawable.f_3, R.drawable.f_4, R.drawable.f_5, R.drawable.f_6, R.drawable.f_7, R.drawable.f_8, R.drawable.f_9, R.drawable. F_l0, Rkdravblekf_ll, Rkdravblekf_l2, Rkdravblekf_l3, Rkdravblekf_l4, Rkdravblekf_l5, Rkdravblekf_l6, Rkdravblekf_l7, Rkdravblekf_l8, R.drawable.f_19, R.drawa Ble.f_20, R.drawable.f_21, R.drawable.f_22, R.drawable.f_23, R.drawable.f_24, R.drawable.f_25, R.drawable.f_26, R .drawable.f_27, R.drawable F_28,}; Override public zero at @Receive (reference reference, intention intent) {if (intent.getAction (.) Equals ("android.appwidget.intent.action.CHANGE_PICTURE")); Remote power remote = new remote power (context.getPackageName (), R. layout.videt_layout); Remote.setImageViewResource (R.id.widget_image_view, getImageToSet ()); } Private IITImageToset () {current image ++; Return current image = current image% images.length; }} & Lt; Relative layout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" Android: layout_width = "match_parent" Android: Leaut_heht Android: Paddingbotm = "@Demon / Activity_WorldMargin" Android: Padding Lift = "@Demon / Activity_Horizontal_Margin" Android: PaddingRight = "@Demon / Activity_Horizontal_Margin" Android: PaddingTop = "@Demon / Activity_WorldMargin" Android: Android: Background = "@color / black" tool: reference = "main activity" & gt; & Lt; imageView android: id = "@ + id / imageView" Android: Layout_width = "Match_parent" Android: Layout_height = "Match_parent" Android: contentDescription = "@ string / image_view_text" android: src = "@ drawable / J_1" / & gt; & Lt; Button android: id = "@ + id / upButton" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignRight = "@ + id / imageView" Android: layout_alignTop = "@ + id / imageView" Android: Text = "@ string / button_view_text_up" /> & Lt; Button android: id = "@ + id / downButton" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignLeft = "@ + id / imageView" Android: layout_alignTop = "@ + id / imageView" Android: Text = "@ string / button_view_text_down" /> & Lt; / RelativeLayout & gt;
In your constructor:
public widgetint receiver () {CurrentImage = Calendar.getInstance (). Receive (Calendar DAY_OF_YEAR); }
Comments
Post a Comment