diff --git a/app/src/main/java/org/ntlab/irisclient/CreateRoomActivity.java b/app/src/main/java/org/ntlab/irisclient/CreateRoomActivity.java index e4d7429..8354a6f 100644 --- a/app/src/main/java/org/ntlab/irisclient/CreateRoomActivity.java +++ b/app/src/main/java/org/ntlab/irisclient/CreateRoomActivity.java @@ -14,6 +14,7 @@ import android.widget.Button; import android.widget.ImageButton; import android.app.AlertDialog; +import android.widget.EditText; public class CreateRoomActivity extends AppCompatActivity { @@ -29,10 +30,10 @@ actionBar.hide(); } //------------------------------------------------------------------------------------------------------------------------------------------ - //前の画面に遷移 + //バックボタンを押した場合、前の画面に遷移 Intent intent = getIntent(); - ImageButton imageButton = (ImageButton) findViewById(R.id.imageButton); // view経由でimageButtonを探す + ImageButton imageButton = (ImageButton) findViewById(R.id.backButton); // view経由でimageButtonを探す imageButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent i = new Intent(v.getContext(), MainActivity.class); @@ -40,46 +41,27 @@ } }); -/*------------------------------------------------------------------------------------------------------------------------------------------- - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.main, menu); - return true; - } +//------------------------------------------------------------------------------------------------------------------------------------------- - public void CreateRoomButton(View view){ - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage("ニックネームを入力してください"); - builder.setPositiveButton("確認", new DialogInterface.OnClickListener() { - - AlertDialog dialog = builder.create(); - dialog.show(); - }); - } - -------------------------------------------------------------------------------------------------------------------------------------------*/ - //部屋を作る次の画面に遷移 + //ボタンをクリックすると、部屋を作る次の画面に遷移 Button nextButton = findViewById(R.id.CreateRoomButton); + EditText text = (EditText) findViewById(R.id.nicknameEditText); nextButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - Intent i = new Intent(getApplication(), MainActivity/*OwnerActivityに変更する*/.class); - startActivity(i); + + //ニックネームが入力されていない場合エラーメッセージを表示する + if (text.getText().toString().isEmpty()) { + text.setError("ニックネームを入力されていません"); + + //ニックネームが入力されていれば次の画面へ + } else { + Intent i = new Intent(getApplication(), MainActivity/*OwnerRoomActivityに変更する*/.class); + startActivity(i); + } + } }); } - - -// public void onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { -// View view = inflater.inflate(R.layout.activity_create_room, container, false); -// ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton); // view経由でimageButtonを探す -// imageButton.setOnClickListener(new View.OnClickListener() { -// public void onClick(View v) { -// Intent i = new Intent(v.getContext(), MainActivity.class); -// startActivity(i); -// } -// }); -// } - - } +