Skip to content Skip to sidebar Skip to footer

No Adapter Attach,skipping Layout

I am getting an error saying no adapter attach skipping layout.and the list doesn't appear in when emulator runs.please help.I cant see anything in list.screen appears blank.other

Solution 1:

Because Your _songs ArrayList is Empty.

Solution 2:

Try this

privatevoidloadSongs(){
Uriuri= MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Stringselection= MediaStore.Audio.Media.IS_MUSIC+"!=0";
cursor =getActivity().getContentResolver().query(uri,null,selection,null,null);
    if(cursor != null){
        if(cursor.moveToFirst()){
            do{
                Stringname= cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
                Stringartist= cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST));
                intsongPath= cursor.getColumnIndex(MediaStore.Audio.Media.DATA);

                songInfos=newsongInfo(name,artist,songPath);
                _songs.add(s);
                 songAdapter1 = newsongAdapter(_songs,getActivity());
                 recyclerView.setAdapter(songAdapter1);

            }while (cursor.moveToNext());
        }
        cursor.close();
    }
}

Solution 3:

In loadSongs, you create a new adapter instance, which is not in any way connected with your RecyclerView. Instead call

songAdapter1.notifyDatasetChanged();

after you added all items to your _songs List

Post a Comment for "No Adapter Attach,skipping Layout"