Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your adapter you need to bind your item_list resource with your list of notes like this:</p> <pre><code>class CustomListAdapter extends BaseAdapter { Context mContext; List&lt;String&gt; mList; public CustomListAdapter (Context context, List&lt;String&gt; list) { mList = list; mContext = context; } @Override public int getCount() { return mList.size(); } @Override public String getItem(int position) { return mList.get(position); } @Override public long getItemId(int position) { return 0; } // This method is called to draw each row of the list @Override public View getView(int position, View convertView, ViewGroup parent) { // here you inflate the layout you want for the row final View view = View.inflate(mContext, R.layout.item_list, null); // you bind the layout with the content of your list // for each element of your list of notes, the adapter will create a row and affect the right title final TextView noteTitle= (TextView)view.findViewById(R.id.note_title); noteTitle.setText(mList.getItem(position)); return view; } } } </code></pre> <p>Here is the file item_list.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent"&gt; &lt;TextView android:id="@+id/note_title" android:layout_width="match_parent" android:layout_height="wrap_content"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>And then to create the adapter, write in the populate method:</p> <pre><code> // Populate Method private void populateList() { List&lt;String&gt; values = new ArrayList&lt;String&gt;(); for(Note note : notes) { values.add(note.getTitle()); } CustomListAdapter CustomAdapter = new CustomListAdapter(this, values); notesListView.setAdapter(CustomAdapter); } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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