Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to put custom list view inside fragments??fragments are a part of a view pager
    text
    copied!<p>is there any way of doing this without extending the class to "ListFragment"?i don't wan't to use Listfragments because then i will have to change myviewpager adapter..but if there is no choice left i will have to :( .Also i tried using Listfragments but i was unable to make the listfragments a part of viewpager,in other words, i was unable to populate Listfragments in a viewpager,</p> <p>this is just a part of code showing how i populated fragments </p> <pre><code> List&lt;Fragment&gt; fragments = new Vector&lt;Fragment&gt;(); fragments.add(Fragment.instantiate(this, FragmentSongs.class.getName())); fragments.add(Fragment.instantiate(this, FragmentArtists.class.getName())); fragments.add(Fragment.instantiate(this, FragmentPlaylists.class.getName())); fragments.add(Fragment.instantiate(this, FragmentAlbums.class.getName())); ViewPagerAdapter adapter = new ViewPagerAdapter(super.getSupportFragmentManager(), fragments); ViewPager pager = (ViewPager)super.findViewById(R.id.viewpager); </code></pre> <p>is their any parallel code to this, that can be used for listfragments?</p> <pre><code>here is the code: package sourcecode.jazzplayer; import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.List; import android.content.Context; import android.media.MediaPlayer; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.ListFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; class Mp3Filter implements FilenameFilter{ public boolean accept(File dir,String name) { return (name.endsWith(".mp3"))|| (name.endsWith(".Mp3")) ||(name.endsWith(".MP3"));//searching for the files } } public class FragmentSongs extends Fragment { private static final String Sd_Path=new String("/sdcard/"); //setting up the source path //private MediaPlayer mp =new MediaPlayer(); @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // updatePlaylist() ; //updatePlaylist(); View view = inflater.inflate(R.layout.fragment_a, container, false); ListView SngList = (ListView) view.findViewById(R.id.SongList); SongDetails Detail = null; Context _c = null ; ArrayList&lt;SongDetails&gt; Songinfo; // AdapterView.AdapterContextMenuInfo info; Songinfo = new ArrayList&lt;SongDetails&gt;(); File home=new File(Sd_Path); if(home.listFiles(new Mp3Filter()).length&gt;0) { for(File file:home.listFiles(new Mp3Filter())) { Detail.setSong(file.getName()); Detail.setArtist(file.getName()); Detail.setAlbum(file.getName()); Songinfo.add(Detail); SngList.setAdapter(new CustomAdapter(Songinfo , _c)); } } return view; } } /*private void updatePlaylist() { SongDetails Detail = null ; Context _c = null ; ArrayList&lt;SongDetails&gt; Songinfo; AdapterView.AdapterContextMenuInfo info; Songinfo = new ArrayList&lt;SongDetails&gt;(); File home=new File(Sd_Path); if(home.listFiles(new Mp3Filter()).length&gt;0) { for(File file:home.listFiles(new Mp3Filter())) { Detail.setSong(file.getName()); Detail.setArtist(file.getName()); Detail.setAlbum(file.getName()); Songinfo.add(Detail); SngList.setAdapter(new CustomAdapter(Songinfo , _c)); } } } } */ </code></pre>
 

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