diff --git a/app/src/main/java/com/example/citrusclient/views/CreateTodoFragment.java b/app/src/main/java/com/example/citrusclient/views/CreateTodoFragment.java index ffe559b..cbc6603 100644 --- a/app/src/main/java/com/example/citrusclient/views/CreateTodoFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/CreateTodoFragment.java @@ -2,12 +2,19 @@ import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.NumberPicker; +import android.widget.Spinner; +import com.example.citrusclient.Citrus; import com.example.citrusclient.R; /** @@ -17,6 +24,8 @@ */ public class CreateTodoFragment extends Fragment { + private Citrus citrus; + // TODO: Rename parameter arguments, choose names that match // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER private static final String ARG_PARAM1 = "param1"; @@ -26,6 +35,10 @@ private String mParam1; private String mParam2; + private int year; + private int month; + private int day; + public CreateTodoFragment() { // Required empty public constructor } @@ -55,6 +68,8 @@ mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } + + } @Override @@ -63,4 +78,51 @@ // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_create_todo, container, false); } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + + NumberPicker numberPickerYear = view.findViewById(R.id.numberPickerYear); + numberPickerYear.setValue(citrus.getCurYear()); + numberPickerYear.setMinValue(2024); + numberPickerYear.setMaxValue(2054); + year = numberPickerYear.getValue();//設定年を取得 + + NumberPicker numberPickerMonth = view.findViewById(R.id.numberPickerMonth); + numberPickerYear.setValue(citrus.getCurMonth()); + numberPickerMonth.setMinValue(1); + numberPickerMonth.setMaxValue(12); + month = numberPickerMonth.getValue();//設定月を取得 + + NumberPicker numberPickerDay = view.findViewById(R.id.numberPickerDay); + numberPickerYear.setValue(citrus.getCurDay()); + numberPickerDay.setMinValue(1); + numberPickerDay.setMaxValue(31); + day = numberPickerDay.getValue();//設定月を取得 + + Button cancelButton = view.findViewById(R.id.todo_cancel_button); + cancelButton.setOnClickListener(v->{ + ((MainActivity)getActivity()).backFragment(); + }); + + Button createButton = view.findViewById(R.id.todo_create_button); + cancelButton.setOnClickListener(v->{ + createTodo(); + ((MainActivity)getActivity()).backFragment(); + }); + + Spinner spinner; + spinner = view.findViewById(R.id.select_book_spinner); + String[] books = {"book1", "book2", "book3"}; + ArrayAdapter adapter = new ArrayAdapter<>(requireContext(), androidx.appcompat.R.layout.support_simple_spinner_dropdown_item, books); + adapter.setDropDownViewResource(androidx.appcompat.R.layout.support_simple_spinner_dropdown_item); + spinner.setAdapter(adapter); + } + + //Todo追加時の処理 + private void createTodo() + { + + } + } \ No newline at end of file