Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is what is wrong:</p> <pre><code> public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } </code></pre> <p>In <code>getItem</code> you need to return an instance that represents your object, maybe something like a <code>Music</code> object. And in the <code>getItemId</code> you need return an unique value for that instance.</p> <p>Let's pretend that you load an array with <code>Music</code> instances, something like this:</p> <pre><code>public class MusicAdapter extends BaseAdapter { public class Music { private Long id; private String pathToSd; private Long lenght; } private List&lt;Music&gt; mMusicList; private LayoutInflater mInflater; public MusicAdapter(Context context, List&lt;Music&gt; music) { mMusicList = music; mInflater = LayoutInflater.from(context); } @Override public int getCount() { return mMusicList.size(); } @Override public Object getItem(int position) { return mMusicList.get(position); } @Override public long getItemId(int position) { return mMusicList.get(position).id; //If you aren't saving your list of music in some place like a db //and thus, you don't have an id, you can return -1. } @Override public View getView(int position, View convertedView, ViewGroup parent) { if (convertedView == null) { convertedView = mInflater.inflate(R.layout.your_layout, null); } //Perform your operations over the view here... } } </code></pre> <p>Anyways, I Strongly reccomend you save this list in a db.</p> <p>Hope it helps :]</p>
    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. 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