Andrid Studio插件开发

2016-08-27  本文已影响18人  CatDog118

http://blog.csdn.net/lmj623565791/article/details/51548272

使用IntelliJ IDEA开发

一、新建工程,选择[Intellij Platform Plugin]

二、配置并编写AnAction类

  1. 在创建向导中配置插件信息和快捷键等

    • ActionID:代表该Action的唯一的ID,一般的格式为:pluginName.ID
    • ClassName:类名
    • Name:就是最终插件在菜单上的名称
    • Description:对这个Action的描述信息
  1. 可以在plugin.xml中查看或跟新配置信息

    <actions>
        <action id="TestTranslation.TranslateAction" class="com.ccy.TranslateAction" text="Translate"
            description="translate for selected word">
            <add-to-group group-id="EditMenu" anchor="first"/>
            <keyboard-shortcut keymap="$default" first-keystroke="meta I"/>
        </action>
    </actions>
    
  2. 编写具体实现

    public class MyAction extends AnAction {
    
        // 点击菜单时触发
        @Override
        public void actionPerformed(AnActionEvent e) {
            Messages.showMessageDialog(
                    "Hello World!",
                    "Information",
                    Messages.getInformationIcon());
        }
    }
    

三、测试运行

点击[Run],默认启动一个新的IntelliJ IDEA的界面

四、部署插件

  1. plugin.xml中填写信息

    <id>com.your.company.unique.plugin.id</id>
    
    <name>Plugin display name here</name>
    
    <version>1.0</version>
    
    <vendor email="support@yourcompany.com" url="http://www.yourcompany.com">YourCompany</vendor>
    
    <description>
        <![CDATA[
          Enter short description for your plugin here.<br>
          <em>most HTML tags may be used</em>
        ]]>
    </description>
    
    <change-notes>
        <![CDATA[
          Add change notes here.<br>
          <em>most HTML tags may be used</em>
        ]]>
    </change-notes>
    
  2. 输出jar包

更多

上一篇 下一篇

猜你喜欢

热点阅读