Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>what code must be added (changes to be made) for MainActivity.java to achive the functionalityusing bean class employee.java</p> </blockquote> <p>It' not too tricky. If you don't want some special / custom ListView (custom items in list) you just need:</p> <ul> <li>properly initialise ListView</li> <li>create ListAdapter (in your case would be enough system build-in ArrayAdapter</li> <li>to be able to show name of employees you need to override <code>toString()</code> method in your Employee class (otherwise will be printed string representation ob object that is not very human readable)</li> </ul> <h2>Example:</h2> <p>Updated class:</p> <pre><code>public class Employee implements Serializable{ private String name; public void setName(String name){ this.name=name; } public String getName(){ return name; } public String toString() { return this.name; } } </code></pre> <p>Example of initialisation and assigning of ArrayAdapter:</p> <pre><code>ListView list = (ListView) findVieById(R.id.listid); ArrayAdapter&lt;Employee&gt; adapter = new ArrayAdapter&lt;Employee&gt;(&lt;context&gt;, android.R.layout.simple_list_item_1, &lt;list&gt;); list.setAdapter(adapter); </code></pre> <h2>Note:</h2> <p>If you want customize list items you need to create own XML layout for list-row a implement own ListAdapter (extending for example from BaseAdapter). If you don't know how to start look at:</p> <ul> <li><a href="http://www.vogella.com/articles/AndroidListView/" rel="nofollow">Android ListView - Tutorial</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload