nerdexam
Android

OA0-002 · Question #56

The following code applies to a dialog layout defined in XML. Which is the correct code that goes into (1)? (Assume the dialog layout is correctly defined in res/layout/custom_dialog.xml, and there…

The correct answer is B. dialog.setContentView(R.layout.custom_dialog). See the full explanation below for the reasoning.

Question

The following code applies to a dialog layout defined in XML. Which is the correct code that goes into (1)? (Assume the dialog layout is correctly defined in res/layout/custom_dialog.xml, and there are no other problems in the rest of the application.)

Options

  • Adialog.inflate(R.layout.custom_dialog);
  • Bdialog.setContentView(R.layout.custom_dialog);
  • Cdialog.getinflate().inflate(R.layout.custom_dialog);
  • Ddialog.setLayout(R.layout.custom_dialog);

How the community answered

(60 responses)
  • A
    5% (3)
  • B
    83% (50)
  • C
    10% (6)
  • D
    2% (1)

Community Discussion

No community discussion yet for this question.

Full OA0-002 Practice