32
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

  1. 下記をコピペ
#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)
    }
}
  1. 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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?