2014-03-30 43 views
0

我被困在一個很小的錯誤, 我要放置Baseadapter類的getview內的條件。 如果條件爲真,它不應該膨脹,否則它應該在listview中膨脹。BaseAdapter GetView隨着條件

一些幫助將非常感激

這是我的代碼

public View getView(final int position, View convertView, ViewGroup parent) { 

     View itemView = inflater.inflate(R.layout.slidelistrow, parent, false); 
     // Get the position 
     resultp = data.get(position); 

     if(resultp.get(MainFragment.TAG_PACKAGE).equals(Constants.PACKAGE_NAME)) 
     { 
      return null; 
     }else 
     { 
      return itemView; 
     } 

    } 

回答

0

你做錯了。 getView不能返回null,否則你的應用程序將崩潰。你所要做的就是提交你想要顯示的確切數據集,這意味着你的data必須包含正是你想要的ListView

顯示什麼