0

Right I've looked at a lot of questions, answers and tutorials but none have helped me so my question is my last hope...

On my clock widgets config activity i want to be able to have image button so that the user can change the background on the config menu, like it is on the HD Widgets app, but with a different background of course and so far i have this

 @Override
    protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);
            setContentView(R.layout.widget_config);
            setResult(RESULT_CANCELED);
 }

    int mAppWidgetId;
    @SuppressWarnings({ "unused" })
    private void showAppWidget() {

       mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
       Intent intent = getIntent();
       Bundle extras = intent.getExtras();
       if (extras != null) {
           mAppWidgetId = extras.getInt(EXTRA_APPWIDGET_ID,INVALID_APPWIDGET_ID);
           final ImageButton button1 = (ImageButton) findViewById(R.id.button1);
           button1.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View arg0) {
        button1.setImageResource(R.drawable.background3);
            AppWidgetProviderInfo providerInfo = AppWidgetManager.getInstance(
                                    getBaseContext()).getAppWidgetInfo(mAppWidgetId);
            String appWidgetLabel = providerInfo.label;
            Intent startService = new Intent(WidgetConfigActivity.this, null);
            startService.putExtra(EXTRA_APPWIDGET_ID, mAppWidgetId);
            startService.setAction("FROM CONFIGURATION ACTIVITY");
            setResult(RESULT_OK, startService);
            startService(startService);
            finish();
            if (mAppWidgetId == INVALID_APPWIDGET_ID) {
            Log.i("I am invalid", "I am invalid");
            finish();
            }
    }

From the answers I've looked at, you need to use RemoteViews but I'm not entirely sure how to implement that into my code so that where i need some help Thank you

Sasi Kathimanda
  • 1,788
  • 3
  • 25
  • 47
SkintMedia
  • 33
  • 1
  • 5

1 Answers1

0

You get the RemoteViews like this

  RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

Then you change background like this

remoteViews.setInt(R.id.some_view, "setBackgroundResource", R.drawable.my_color);
Greg Ennis
  • 14,917
  • 2
  • 69
  • 74