i'm making music player , i'm trying display artist names using listfragment. here code:
import android.app.listfragment; import android.database.cursor; import android.os.bundle; import android.provider.mediastore; import android.support.v4.app.fragmentactivity; import android.support.v4.app.loadermanager; import android.support.v4.content.cursorloader; import android.support.v4.content.loader; import android.support.v4.widget.cursoradapter; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; public class albumsfragment extends listfragment implements loadermanager.loadercallbacks < cursor > { albumsadapter madapter; @ override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view myfragmentview = inflater.inflate(r.layout.tabs_list, container, false); return myfragmentview; } @ override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); madapter = new albumsadapter(getactivity(), null); setlistadapter(madapter); getloadermanager().initloader(0, null, this); } static final string[] album_summary_projection = { mediastore.audio.albums._id, mediastore.audio.albums.album }; public loader < cursor > oncreateloader(int id, bundle args) { string select = null; return new cursorloader(getactivity(), mediastore.audio.albums.external_content_uri, album_summary_projection, select, null, null); } public void onloadfinished(loader < cursor > loader, cursor data) { madapter.swapcursor(data); } public void onloaderreset(loader < cursor > loader) { madapter.swapcursor(null); } }
i error saying: method initloader(int, bundle, loadermanager.loadercallbacks) in type loadermanager not applicable arguments (int, null, albumsfragment)
did see in imports ?
import android.support.v4.app.fragmentactivity; import android.support.v4.app.loadermanager; import android.support.v4.content.cursorloader; import android.support.v4.content.loader; import android.support.v4.widget.cursoradapter;
it means using support version of loadermanager.
so should replace
getloadermanager().initloader(0, null, this);
with
getsupportloadmanager().initloader(0, null, this);
Comments
Post a Comment