我可以在Android工作室使用快捷键来生成javadoc评论吗?

如果不是,生成javadoc注释的最简单方法是什么?


当前回答

我找不到任何生成javadoc注释的快捷方式。但是如果在方法声明之前输入/**并按Enter,则会自动生成javadoc注释块。

阅读这篇文章获取更多信息。

其他回答

我不确定我完全理解了这个问题,但是可以在这里找到一个键盘快捷键的列表-希望这对你有帮助!

下面是一个来自Oracle的JavaDoc注释示例:

/**
 * Returns an Image object that can then be painted on the screen. 
 * The url argument must specify an absolute {@link URL}. The name
 * argument is a specifier that is relative to the url argument. 
 * <p>
 * This method always returns immediately, whether or not the 
 * image exists. When this applet attempts to draw the image on
 * the screen, the data will be loaded. The graphics primitives 
 * that draw the image will incrementally paint on the screen. 
 *
 * @param  url  an absolute URL giving the base location of the image
 * @param  name the location of the image, relative to the url argument
 * @return      the image at the specified URL
 * @see         Image
 */
 public Image getImage(URL url, String name) {
        try {
            return getImage(new URL(url, name));
        } catch (MalformedURLException e) {
            return null;
        }
 }

基本格式可以通过以下两种方式自动生成:

将光标置于方法上方,并键入/** + Enter 将光标定位在方法名上,按Alt + Enter >,单击Add JavaDoc

可以使用IDE的自动完成功能自动添加Javadoc注释。尝试输入/**并按Enter生成一个示例Javadoc注释。

 /**
 *
 * @param action          The action to execute.
 * @param args            The exec() arguments.
 * @param callbackContext The callback context used when calling back into JavaScript.
 * @return
 * @throws JSONException
 */

要在方法声明之前输入/**键并按Enter生成注释。它将生成javadoc注释。

例子:

/**
* @param a
* @param b
*/

public void add(int a, int b) {
    //code here
}

欲了解更多信息,请查看链接 https://www.jetbrains.com/idea/features/javadoc.html

在Android studio中,我们有几种自动生成评论的方法:

我的方法:

通过输入/**,然后按Enter,你可以生成下一个评论行,它会自动生成参数,等等,但当你需要热键为这个签出方法II在下面。

**方法二: **

1 - 转到顶部菜单

2 -文件>设置

3 -在“设置”中选择“Keymap”

4 -在右上角搜索栏搜索“Fix Doc”

5 -从结果中选择“fix doc comment”,双击它

6 -双击后,从打开的下拉菜单中选择“添加键盘快捷方式”

7—按键盘上的快捷键

8 -转到你的代码,在你想添加一些注释的地方按快捷键

9 -好好享受!