本文介绍了启用/禁用编程活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序,我一直保持为

I have an activity in in my app which I have kept as

android:enabled="false"

现在我想要一个按钮被点击时,它应该换到

now I want that when a button is clicked it should get changer to

android:enabled="true"

我怎样才能做到这一点?

How can I do this?

推荐答案

下面是一个例子如何启用/禁用活动:

Here's an example how to enable/disable an Activity:

    PackageManager pm = getPackageManager(); 
    pm.setComponentEnabledSetting(new ComponentName(this, com.packagename.MyActivity.class),
                                  PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

    pm.setComponentEnabledSetting(new ComponentName(this, com.packagename.MyActivity.class),
                                  PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

这篇关于启用/禁用编程活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 20:40