<div>기본적인 회원가입 엑티비티입니다.</div> <div>AVD나 디바이스 내에서도 잘 작동 하고 입력값도 문제없이 DB에 잘 들어갑니다만 빨간색 밑줄부터는 작동이 안됩니다.</div> <div>코드는 다음과 같습니다.</div> <div><br></div> <div><br></div> <div><pre style="font-family:'굴림체';font-size:9pt;"><span style="color:#000080;font-weight:bold;">public class </span>RegisterActivity <span style="color:#000080;font-weight:bold;">extends </span>AppCompatActivity {<br><br><span style="color:#808000;">@Override<br></span><span style="color:#808000;"> </span><span style="color:#000080;font-weight:bold;">protected void </span>onCreate(Bundle savedInstanceState) {<br><span style="color:#000080;font-weight:bold;">super</span>.onCreate(savedInstanceState);<br> setContentView(R.layout.<span style="color:#660e7a;font-weight:bold;font-style:italic;">activity_register</span>);<br><br><span style="color:#000080;font-weight:bold;">final </span>EditText idText = (EditText) findViewById(R.id.<span style="color:#660e7a;font-weight:bold;font-style:italic;">phoneNumber</span>);<br><span style="color:#000080;font-weight:bold;">final </span>EditText passwordText = (EditText) findViewById(R.id.<span style="color:#660e7a;font-weight:bold;font-style:italic;">password</span>);<br><span style="color:#000080;font-weight:bold;">final </span>EditText nicknameText = (EditText) findViewById(R.id.<span style="color:#660e7a;font-weight:bold;font-style:italic;">nickname</span>);<br><span style="color:#000080;font-weight:bold;">final </span>EditText univText = (EditText) findViewById(R.id.<span style="color:#660e7a;font-weight:bold;font-style:italic;">universe</span>);<br><br> Button registerBtn = (Button) findViewById(R.id.<span style="color:#660e7a;font-weight:bold;font-style:italic;">registerBtn</span>); <br> registerBtn.setOnClickListener(<span style="color:#000080;font-weight:bold;">new </span>View.OnClickListener() {<br><span style="color:#808000;">@Override<br></span><span style="color:#808000;"> </span><span style="color:#000080;font-weight:bold;">public void </span>onClick(View view) {<br> String id = <span style="color:#660e7a;">idText</span>.getText().toString();<br> String password = <span style="color:#660e7a;">passwordText</span>.getText().toString();<br> String nickname = <span style="color:#660e7a;">nicknameText</span>.getText().toString();<br> String univ = <span style="color:#660e7a;">univText</span>.getText().toString();<br><br> Response.Listener<String> responseListener = <span style="color:#000080;font-weight:bold;">new </span>Response.Listener<String>() {<br><span style="color:#808000;">@Override<br></span><span style="color:#808000;"> </span><span style="color:#000080;font-weight:bold;">public void </span>onResponse(String response) {<br><span style="color:#000080;font-weight:bold;">try </span>{<br> JSONObject jsonResponse = <span style="color:#000080;font-weight:bold;">new </span>JSONObject(response);<br><u></u> <span style="color:#000080;font-weight:bold;">if</span>(success){<br> AlertDialog.Builder builder = <span style="color:#000080;font-weight:bold;">new </span>AlertDialog.Builder(RegisterActivity.<span style="color:#000080;font-weight:bold;">this</span>);<br> builder.setMessage(<span style="color:#008000;font-weight:bold;">"회원등록 성공"</span>).setPositiveButton(<span style="color:#008000;font-weight:bold;">"확인"</span>,<span style="color:#000080;font-weight:bold;">null</span>).create().show();<br><br> Intent intent = <span style="color:#000080;font-weight:bold;">new </span>Intent(RegisterActivity.<span style="color:#000080;font-weight:bold;">this</span>, MainActivity.<span style="color:#000080;font-weight:bold;">class</span>);<br> RegisterActivity.<span style="color:#000080;font-weight:bold;">this</span>.startActivity(intent);<br> }<br><span style="color:#000080;font-weight:bold;">else</span>{<br> AlertDialog.Builder builder = <span style="color:#000080;font-weight:bold;">new </span>AlertDialog.Builder(RegisterActivity.<span style="color:#000080;font-weight:bold;">this</span>);<br> builder.setMessage(<span style="color:#008000;font-weight:bold;">"회원등록 실패"</span>).setNegativeButton(<span style="color:#008000;font-weight:bold;">"다시시도"</span>,<span style="color:#000080;font-weight:bold;">null</span>).create().show();<br> }<br> }<br><span style="color:#000080;font-weight:bold;">catch </span>(JSONException e) {<br> e.printStackTrace();<br> }<br> }<br> };<br> RegisterRequest registerRequest = <span style="color:#000080;font-weight:bold;">new </span>RegisterRequest(id, password, nickname, univ, responseListener);<br> RequestQueue queue = Volley.<span style="font-style:italic;">newRequestQueue</span>(RegisterActivity.<span style="color:#000080;font-weight:bold;">this</span>);<br> queue.add(registerRequest);<br> }<br> });<br> }<br>}</pre></div> <div><br></div> <div><br></div> <div><br></div> <div>즉, 메시지창을 띄우기 위한 if(success)부분부터<span style="font-family:'굴림체';font-size:9pt;"> 작동하지 않습니다. </span></div> <div><span style="font-family:'굴림체';font-size:9pt;">빨간색 밑줄 위에다가 </span><span style="font-family:'굴림체';font-size:9pt;">AlertDialog.Builder</span><span style="font-family:'굴림체';font-size:9pt;"> 넣으면 문제없이 잘 작동하구요.</span></div> <div>구글링을 해봐도 다들 이 코드랑 별 차이도 없고 이부분에서 문제생기는 경우는 안보이던데 혹시 어느 부분에서 문제가 있는걸까요?</div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.