2013-08-07 32 views
0

我想設置一個ListView,但希望活動在Sherlock標籤中。listFilter在SherlockListFragment

這裏是我的代碼

public class PlayListActivity extends SherlockListFragment{ 
    // Songs list 
    public ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>(); 

    @Override 
    public SherlockFragmentActivity getSherlockActivity() { 
     return super.getSherlockActivity(); 
    } 

    @Override 
    public void onViewCreated(View view, Bundle savedInstanceState) { 
     super.onViewCreated(view, savedInstanceState); 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     // Get the view from fragmenttab3.xml 
     View view = inflater.inflate(R.layout.playlist, container, false); 
     ArrayList<HashMap<String, String>> songsListData = new ArrayList<HashMap<String, String>>(); 

     SongsManager plm = new SongsManager(); 
     // get all songs from sdcard 
     this.songsList = plm.getPlayList(); 

     // looping through playlist 
     for (int i = 0; i < songsList.size(); i++) { 
      // creating new HashMap 
      HashMap<String, String> song = songsList.get(i); 

      // adding HashList to ArrayList 
      songsListData.add(song); 
     } 

     // Adding menuItems to ListView 

     ListAdapter Ladapter = new SimpleAdapter(this, songsListData, 
       R.layout.playlist_item, new String[] { "songTitle" }, new int[] { 
         R.id.songTitle }); 

聲明ListAdapter當我得到的只是上面在這裏的錯誤,它說SimpleAdapter是不確定的。 它工作正常,當類擴展ListActivity,但因爲我想要標籤和刷卡我擴展sherlockListActivity,我猜這個類是不可用在Sherlock 任何方法可以解決這個問題?

回答

0

如果你不是usign的片段,然後從SherlockListActivity其他 擴展你的活動類從SherlockFragmentActivity並添加SherlockListFragment片段。

+0

我正在使用片段 我希望我的片段之一是列表視圖 請解釋更多,我該如何添加SherlockListFragment – user1559736

相關問題