diff --git a/app/src/main/java/com/example/cosmosclient/views/CreateGroupActivity.java b/app/src/main/java/com/example/cosmosclient/views/CreateGroupActivity.java index d83bf9e..605afc8 100644 --- a/app/src/main/java/com/example/cosmosclient/views/CreateGroupActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/CreateGroupActivity.java @@ -1,10 +1,14 @@ package com.example.cosmosclient.views; +import android.media.Image; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; import android.view.View; import android.widget.Button; import android.widget.EditText; +import android.widget.ImageButton; import android.widget.Toast; import com.example.cosmosclient.R; @@ -19,6 +23,7 @@ import retrofit2.converter.jackson.JacksonConverterFactory; public class CreateGroupActivity extends AppCompatActivity { + Button createGroupButton; @Override protected void onCreate(Bundle savedInstanceState) { @@ -27,9 +32,14 @@ //各種IDを取得 final EditText groupNameText = findViewById(R.id.groupNameText); - Button createGroupButton = findViewById(R.id.createGroupButton); + createGroupButton = findViewById(R.id.createGroupButton); final String uId,token; + //ボタン有効化&監視 + createGroupButton.setEnabled(false); + createGroupButton.setBackgroundColor(0xaa808080); + groupNameText.addTextChangedListener(new CreateGroupActivity.GenericTextWatcher(groupNameText)); + //グループ作成に必要な情報の取得 Cosmos app = (Cosmos) getApplication(); uId = app.getuId(); @@ -90,4 +100,29 @@ } }); } -} + //テキスト欄監視 + private class GenericTextWatcher implements TextWatcher { + private View view; + + private GenericTextWatcher(View view){ + this.view = view; + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count,int after){/*記述不要*/}; + @Override + public void onTextChanged(CharSequence s, int start, int before, int count){/*記述不要*/}; + + @Override + public void afterTextChanged(Editable s){ + //ボタン有効&無効 + if(s.length()>0){ + createGroupButton.setEnabled(true); + createGroupButton.setBackgroundColor(0xaa009688); + }else{ + createGroupButton.setEnabled(false); + createGroupButton.setBackgroundColor(0xaa808080); + } + } + } +} \ No newline at end of file