Android Studio 快速创建Activity、Fragment模板

2017/9/29 posted in  Android

2017110415097859584759.gif
2017110415097859584759.gif

自行复制粘贴在Settings>Editor>File and Code Templates新建一个

20171104150978590123238.png
20171104150978590123238.png

Activity

可以自行将AppCompatActivity换成自己的BaseActivity,不要忘记更改import哦

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}

#end
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
/**
* description-><一句话功能简介>
* @author SLJ
* @time ${DATE}
*/
class ${NAME} : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }
}

Fragment

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}

#end
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.app.Fragment
/**
* description-><一句话功能简介>
* @author SLJ
* @time ${DATE}
*/
class ${NAME} : Fragment() {
    
    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
        val view = inflater?.inflate(, container, false)
        return view!!
    }
}