사용자가 활동 내에서 옵션 메뉴를 클릭하면 대화 상자를 표시하려고합니다. 먼저 Dialog 클래스를 사용하여이 작업을 수행하려고했습니다. 코드는 다음과 유사합니다.Dialog 클래스를 직접 인스턴스화하는 것이 왜 바람직하지 않습니까?
final Dialog d = new Dialog(this);
d.setContentView(R.layout.customDialog);
d.setTitle("Sample title");
data = (EditText) d.findViewById(R.id.data);
button = (Button) d.findViewById(R.id.aButton);
d.show();
button.setOnClickListner(new View.OnClickListner() {
// grab data from edittext and save it to some var
d.dismiss();
});
이런 식으로. dev 가이드는 Dialog 클래스를 직접 인스턴스화하지 않는다고 제안합니다. 이 접근법에 특히 나쁜 점이 있습니까?