단추 누르기에 나타나는 사용자 지정 대화 상자가 필요합니다. 여기 내 코드는 다음과 같습니다.새 대화 상자에 어떤 문맥을 사용합니까?
Button button3 = (Button) findViewById(R.id.Button03);
button3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Dialog custdialog = new Dialog(this);
custdialog.setContentView(R.layout.custom_drink);
custdialog.setTitle("Custom Drink");
custdialog.setCancelable(false);
/etc.
그러나이 줄에는 최종 대화 상자 custdialog = new 대화 (this);
"생성자 대화 상자 (새 View.OnClickListener() {})가 정의되지 않았습니다."라는 오류가 발생합니다.
"다른 것"으로 바꾸려고 시도했지만 행운이 없습니다.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.settings:
final Dialog settingsdialog = new Dialog(this);
settingsdialog.setContentView(R.layout.custom_dialog);
settingsdialog.setTitle("Settings");
settingsdialog.setCancelable(false);
그 하나는 잘 작동 ... : 그것은 내 프로젝트 (다른 이름과 물건 제외) 똑같은 일을 가지고 있기 때문에 나는이 같은 스위치 (아래,이 라인에 오류가 발생하는 것은 이상 흠.
는
이 대신 Context.getApplicationContext()를 시도 했습니까? – Mike
거기에 "getApplicationContext()"를 넣을 수는 있지만 실행하지만 버튼을 누르면 FC가 생깁니다. –
Context.getApplicationContext() 대신 "컨텍스트를 정의 할 수 없습니다"오류가 발생합니다 –