2011-09-14 9 views
0

現れ延びており、いくつかのコードは次のとおりです。はBaseAdapter iがパブリッククラスMyHomePageAdapterがBaseAdapterを拡張していますNullPointerExceptionが

public static class ViewHolder{ 
    public GridView myfriendsGridView; 
    public Button myfriendsPre,myfriendsNext; 


    public ListView listview; 
    public Button searchBu; 
    public Button footerBu; 
    public EditText editText; 


    public ListView myfans_listview; 
    public Button myfans_searchBu; 
    public EditText myfans_editText; 
} 

@Override 
public View getView(int position, View convertView, ViewGroup parent) { 
    int view = getItemViewType(position); 


if(view==1) 
    { 
     if (convertView == null) 
     { 
       convertView = mInflater.inflate(R.layout.usercenter_myhome_friendschange, null); 
       //holder=new ViewHolder(); 
       holder.listview=(ListView) convertView.findViewById(R.id.myfriend_list); 
       holder.searchBu=(Button) convertView.findViewById(R.id.headbutton); 
       holder.editText=(EditText) convertView.findViewById(R.id.SearchEdit); 
       convertView.setTag(holder); 
     } 
     else 
     { 
      holder=(ViewHolder)convertView.getTag(); 
     } 

     switcher = new ViewSwitcher(context); 

     holder.footerBu = (Button)mInflater.inflate(R.layout.usercenter_myhomepage_myfriends_loadmore, null); 
     holder.footerBu.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 

      ++counter; 
      switcher.showNext(); 


       //new getMyFriendsMoreItems().execute(); 

        if(NUMBER_OF_ITEMS_IN_COLUMN+counter*NUMBER_OF_MOVE>ConstValue.myfriendsListInfo.size()) 
        { 

         MyFriendssubSet=getDataSubset(0,ConstValue.myfriendsListInfo.size(),ConstValue.myfriendsListInfo); 

        } 
        else 
        { 
         MyFriendssubSet=getDataSubset(0, NUMBER_OF_ITEMS_IN_COLUMN+counter*NUMBER_OF_MOVE,ConstValue.myfriendsListInfo); 

        } 


        if(MyFriendssubSet.size()>0) 
        { 

         adapter.setMasteList(MyFriendssubSet); 
         adapter.notifyDataSetChanged(); 

        } 
        switcher.showPrevious(); 
        Log.i("aa", "rr: "+holder.listview); 
        //holder.listview.setSelection(MyFriendssubSet.size()-1-NUMBER_OF_MOVE); 

      } 
     }); 

      View progress = mInflater.inflate(R.layout.usercenter_myhome_myfriends_loading_footer, null); 
      switcher.addView(holder.footerBu); 
      switcher.addView(progress); 
      holder.listview.addFooterView(switcher); 

     if(ConstValue.myfriendsListInfo.size() > 0) 
     { 

      MyFriendssubSet=getDataSubset(0, NUMBER_OF_ITEMS_IN_COLUMN, ConstValue.myfriendsListInfo); 
      adapter =new FriendsLazyAdapter((Activity) context, MyFriendssubSet); 
      holder.listview.setAdapter(adapter); 
     } 

は、私は私のミスで、この中にあることがわかった:()

switcher.showPrevious。 Log.i( "aa"、 "rr:" + holder.listview); //holder.listview.setSelection(MyFriendssubSet.size()-1-NUMBER_OF_MOVE); holder.listview = nullですので、 "//"を削除するとholder.listview.setSelection(MyFriendssubSet.size() - 1-NUMBER_OF_MOVE)を呼び出すことができます。

   lv=holder.listview; 
      View progress = mInflater.inflate(R.layout.usercenter_myhome_myfriends_loading_footer, null); 
      switcher.addView(holder.footerBu); 
      switcher.addView(progress); 
      lv.addFooterView(switcher); 

     if(ConstValue.myfriendsListInfo.size() > 0) 
     { 

      MyFriendssubSet=getDataSubset(0, NUMBER_OF_ITEMS_IN_COLUMN, ConstValue.myfriendsListInfo); 
      adapter =new FriendsLazyAdapter((Activity) context, MyFriendssubSet); 
      lv.setAdapter(adapter); 
     } 

私は、新しいリストビューに問題をholder.listviewを置く:私はコードを変更しているように、それがnullではない

答えて

0

holder.listviewを使用する方法私の質問のでそれはワイル、NullPointerExceptionが表示されます解決済み

関連する問題