【问题标题】:Changing Plugin Action Icon from code从代码更改插件操作图标
【发布时间】:2016-09-10 19:27:13
【问题描述】:

我正在为 Android Studio (Intellij Idea) 开发一个插件。我想在执行操作时更改图标。

但它并没有改变图标。

这里是代码 -

public void actionPerformed(AnActionEvent event) {

        Project project = event.getData(PlatformDataKeys.PROJECT);

        ActionManager actionManager = event.getActionManager();
        AnAction anAction = actionManager.getAction("York.toggle");
        Presentation presentation = anAction.getTemplatePresentation();
        presentation.setIcon(IconLoader.getIcon("/icons/ic_fav_search_24dp.png"));


        /*String adbPath = getAdpPathOnMachine(project);
        BroadcastHelper.main(new String[]{adbPath});*/
    }

【问题讨论】:

    标签: android android-studio plugins intellij-idea


    【解决方案1】:

    使用com.intellij.openapi.actionSystem.AnActionEvent#getPresentation

    【讨论】:

    • 谢谢,我在使用 anAction.getTemplatePresentation(); 时犯了错误而不是 anAction.getPresentation();
    • 那个方法在那个类中不存在
    • OP 的代码实际上是正确的并且对我有用
    • 取决于您是将操作添加到新位置还是更新现有位置。 plugins.jetbrains.com/docs/intellij/basic-action-system.html
    猜你喜欢
    • 2016-01-13
    • 1970-01-01
    • 1970-01-01
    • 2020-08-16
    • 2011-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多