Tamás Bolvári
Tamás Bolvári

Reputation: 3044

How to disable a button in a remote view?

I can make it invisible using the code below, but can't disable it.

RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification);
contentView.setViewVisibility(R.id.buttonToDisable, View.INVISIBLE);

Upvotes: 1

Views: 1444

Answers (2)

tom
tom

Reputation: 2310

no dice trying to update remote view ind. components e.g.:

Button can't use method with RemoteViews: setEnabled(boolean)

try switching out the layout

 if(((WzBlockWordTheme) wzTheme).mForeign) {
           newRemoteViews = new RemoteViews(context.getPackageName(), R.layout.german_clock_wordzoo_vocabr);
        }
        else {
           newRemoteViews = new RemoteViews(context.getPackageName(), R.layout.german_clock_wordzoo_vocabr_wait);
        }

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007494

setEnabled() is a @RemotableViewMethod, at least on the now-current master branch of the source code. Hence, you should be able to use setBoolean():

contentView.setBoolean(R.id.buttonToDisable, "setEnabled", false);

Upvotes: 10

Related Questions