Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6567363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:19:40+00:00 2026-05-25T14:19:40+00:00

i am public class MyHomePageAdapter extends BaseAdapter and some code is: public static class

  • 0

i am public class MyHomePageAdapter extends BaseAdapter and some code is:

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);
         }

i found that my mistake is in this :

switcher.showPrevious();
Log.i(“aa”, “rr: “+holder.listview);
//holder.listview.setSelection(MyFriendssubSet.size()-1-NUMBER_OF_MOVE);
the holder.listview=null,so if i delete “//” can call holder.listview.setSelection(MyFriendssubSet.size()-1-NUMBER_OF_MOVE); it weill appear NullPointerException ,so my question how to used the holder.listview so that it not null

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:19:41+00:00Added an answer on May 25, 2026 at 2:19 pm

    i have modify the code:

                  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);
             }
    

    i put the holder.listview to a new ListView,the problem is solve

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class BobDatabase extends SQLiteOpenHelper{ private static final String DATABASE_NAME = bob.db; private static
public class PackageTabActivity extends ListActivity{ HashMap<String,Object> hm ; ArrayList<HashMap<String,Object>> applistwithicon ; private static final
public class SuperUser extends User implements Serializable{ private static final long serialVersionUID = 1L;
public class upload extends Activity { private static final int CAMERA_REQUEST = 1888; private
public class Test { public static void main(String[] args) { } } class Outer
public class doublePrecision { public static void main(String[] args) { double total = 0;
public class CovariantTest { public A getObj() { return new A(); } public static
public class WrapperTest { static { print(10); } static void print(int x) { System.out.println(x);
public class WrapperTest { public static void main(String[] args) { Integer i = 100;
public class Main3 { public static void main(String[] args) { Integer min = Integer.MIN_VALUE;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.