2015-09-09 97 views
0

我添加了默認的選項卡活動。我有一個帶有listview(menuCardListView)的片段。我想這取決於所選的tab.I已經實現了這個的主要活動中來填充數據(表),該列表視圖:在片段中選中的選項卡上填充Android Listview

public void onTabSelected(ActionBar.Tab tab, FragmentTransaction  fragmentTransaction) { 
    // When the given tab is selected, switch to the corresponding page in 
    // the ViewPager. 
    mViewPager.setCurrentItem(tab.getPosition()); 

    try { 

     ListView listView = (ListView)mViewPager.findViewById(R.id.menuCardListView); 

     List<Product> groupList = new ProductController(mViewPager.getContext()).ProductList(1); 

     MenuCardListViewAdapter adapter = new MenuCardListViewAdapter(this, groupList); 
     listView.setAdapter(adapter); 

    } catch (InterruptedException e) { 
     e.printStackTrace(); 
    } catch (JSONException e) { 
     e.printStackTrace(); 
    } 

} 

ListView控件爲空?我究竟做錯了什麼?

回答