I was reading an Android tutorial and came across this block of code:
protected Dialog onCreateDialog( int id ) { return new AlertDialog.Builder( this ) .setTitle( "Planets" ) .setMultiChoiceItems( _options, _selections, new DialogSelectionClickHandler() ) .setPositiveButton( "OK", new DialogButtonClickHandler() ) .create(); }
Can someone explain how this works? How can you invoke the setTitle(), setMultiChoiceItems(), and other methods like this without specifying an object name. I'm sure it's correct -- I've just never seen it before.
Normally I would do something like:
protected Dialog onCreateDialog( int id ) { Dialog d = new AlertDialog.Builder(this); d.setTitle( "Planets" ); d.setMultiChoiceItems( _options, _selections, new DialogSelectionClickHandler() ); d.setPositiveButton( "OK", new DialogButtonClickHandler() ) d.create(); return d; }
Does anyone know what that type of initialization used in the tutorial is called so I can read about it? I tried to look it up in a java reference book but couldn't find anything on it.
Thanks for your help.