Newer
Older
ToDoApp / app / src / main / java / keijumt / todoapp / addtask / AddEditTaskFragment.kt
package keijumt.todoapp.addtask

import android.arch.lifecycle.ViewModelProviders
import android.databinding.DataBindingUtil
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import keijumt.todoapp.R
import keijumt.todoapp.databinding.FragmentAddEditTaskBinding

/**
 * タスク追加のFragment
 * Created by matsumoto_k on 2018/03/06.
 */
class AddEditTaskFragment : Fragment() {

    lateinit var binding: FragmentAddEditTaskBinding
    lateinit var addEditTaskViewModel: AddEditTaskViewModel

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_add_edit_task, null, false)
        addEditTaskViewModel = ViewModelProviders.of(activity).get(AddEditTaskViewModel::class.java)
        binding.addEditTaskViewModel = addEditTaskViewModel
        lifecycle.addObserver(addEditTaskViewModel)
        return binding.root
    }
}