LoginSignup
32
28

More than 5 years have passed since last update.

KotlinでFragment書くときのテンプレート

Posted at

ただのメモ。

1) Android Studio > Preferences > File and Code Templates で+ボタンを押して作る。

kotlin_fragment_template.png

2) 下記をコピペ

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

import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

#end
#parse("File Header.java")
public class ${NAME} : Fragment() {
    companion object {
        fun getInstance() : ${NAME} {
            return ${NAME}()
        }
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) : View {
        return inflater.inflate(R.layout.something, container, false)
    }
}

3) ContextMenuにTemplateがでて楽だ・・

shortcut.png

32
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
28