import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity {
DatePickerDialog datePickerDialog;
TimePickerDialog timePickerDialog;
Button btn1,btn2,btn3,btn4,btn5,btn6;
private TextView textView1,textView2;
LinearLayout back;
int count=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
back=(LinearLayout)findViewById(R.id.layout);
btn1=(Button)findViewById(R.id.btn1);
btn2=(Button)findViewById(R.id.btn2);
btn3=(Button)findViewById(R.id.btn3);
btn4=(Button)findViewById(R.id.btn4);
btn5=(Button)findViewById(R.id.btn5);
btn6=(Button)findViewById(R.id.btn6);
textView1=(TextView)findViewById(R.id.textView);
textView2=(TextView)findViewById(R.id.textView2);
//커스텀 다이얼로그 버튼
btn6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
final Dialog loginDialog = new Dialog(MainActivity.this);
loginDialog.setContentView(R.layout.custom_dialog);
loginDialog.setTitle("로그인 화면");
Button login =loginDialog.findViewById(R.id.login);
final Button cancel =loginDialog.findViewById(R.id.cancel);
final Button btnc = loginDialog.findViewById(R.id.btnc);
final ImageView imageView = loginDialog.findViewById(R.id.imageView);
final EditText username= loginDialog.findViewById(R.id.username);
final EditText password= loginDialog.findViewById(R.id.password);
btnc.setEnabled(false);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
username.getText().toString();
password.getText().toString();
}
});
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loginDialog.dismiss();
}
});
loginDialog.show();
}
});
}
}
다이얼로그에서 받은 username과 password를 엑티비티xml 텍스트뷰에 출력하게 하고싶은데
에러가납니다 alt엔터로 char스퀸스? 괄호하고 하면 오류는 안나지만 버튼누를시 어플리케이션이 종료됩니다.