Tuesday, 29 January 2013

Implement toString() | Android Tutorial pdf

Implement toString()

To simplify the creation of our ListView, we need to have our restaurant class respond intelligently to toString(). That will be called on each restaurant as it is displayed in our list.
For the purposes of this tutorial, we will simply use the name – later tutorials will make the rows much more interesting and complex.
So, add a toString() implementation on restaurant like this:
public String toString() 
{
return(getName());
}

Recompile and ensure your application still builds.

No comments: