diff --git a/app/src/main/java/com/example/citrusclient/views/CreateBookFragment.java b/app/src/main/java/com/example/citrusclient/views/CreateBookFragment.java index 9d11a24..1984939 100644 --- a/app/src/main/java/com/example/citrusclient/views/CreateBookFragment.java +++ b/app/src/main/java/com/example/citrusclient/views/CreateBookFragment.java @@ -5,6 +5,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import android.view.LayoutInflater; @@ -13,6 +14,10 @@ import android.widget.Button; import com.example.citrusclient.R; +import android.graphics.Color;//ボタンの色変更 +import android.os.Bundle; +import android.widget.Button; + /** * A simple {@link Fragment} subclass. @@ -71,15 +76,26 @@ @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); + super.onViewCreated(view, savedInstanceState); //親クラスである Fragment の onViewCreated() メソッドを呼び出す - //View.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener()) - Button saveButton = (Button)view.findViewById(R.id.save_button); -// saveButton.setOnClickListener(new View.OnClickListener(){ -// public void onClick(View v){ -// Intent intent = Intent(CreateBookFragment.this,MainActivity.class); -// startActivity(intent); -// } -// }) + //ここから書く + // MainActivityにこのフラグメントを設定するした二つのどっちか + //((MainActivity) getContext()).setCreateBookFragment(this);//フラグメントとアクティビティ間での情報のやり取りがあるとき + //((MainActivity) getActivity()).showFragment(new MyBookshelfFragment()); + + view.findViewById(R.id.save_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ((MainActivity) getActivity()).showFragment(new MyBookshelfFragment()); + } + }); + + view.findViewById(R.id.cancel_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ((MainActivity) getActivity()).showFragment(new MyBookshelfFragment()); + } + }); + } } \ No newline at end of file