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 9124503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:35:10+00:00 2026-06-17T06:35:10+00:00

I have a page adapter with two pages from sherlockfragment, but when I change

  • 0

I have a page adapter with two pages from sherlockfragment,
but when I change page from one to two, the page doesn’t update and the screen is a white page.

My adapter page code is:

public class VpiAbsTestActivitynouser extends SherlockFragmentActivity {


private static final String[] CONTENT = new String[] {" 1","2"};

TestFragmentAdapter mAdapter;
 ViewPager mPager;
    PageIndicator mIndicator;

protected void onCreate(Bundle savedInstanceState) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple_tabs);

    mAdapter = new TestFragmentAdapter(getSupportFragmentManager());
    mPager = (ViewPager)findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    mIndicator = (TabPageIndicator)findViewById(R.id.indicator);
    mIndicator.setViewPager(mPager);

}



class TestFragmentAdapter extends FragmentPagerAdapter {        
    private int mCount = CONTENT.length;

    public TestFragmentAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        switch(position) {

        case 0:

            return new customlistnotuser();

        case 1:

            return new anotherpage();


        default:
            return null;

        }
    }

    @Override
    public int getCount() {
        return mCount;
    }


    public CharSequence getPageTitle(int position) {
        return VpiAbsTestActivitynouser.CONTENT[position % VpiAbsTestActivitynouser.CONTENT.length].toUpperCase();
    }

     @Override
        public void destroyItem(View collection, int position, Object view) {
             ((ViewPager) collection).removeView((View) view);
        }



 }

}

And my fragment looks like this:

 public class customlistnotuser extends SherlockFragment  {

// All static variables
static final String URL = "url";
// XML node keys
static final String KEY_TEST = "test"; // parent node
static final String KEY_ID = "id";
static final String KEY_TITLE = "title";
static final String KEY_Description = "description";
static final String KEY_DURATION = "duration";
static final String KEY_THUMB_URL = "thumb_url";
static final String KEY_PRICE = "price";
static final String KEY_URL = "url";



 private ProgressDialog pDialog;


ListView list;
LazyAdapterbeth adapter;
XMLParser parser = new XMLParser();
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);


}



public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    new getFeed().execute();

}

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) 

{

    View thisfragment = inflater.inflate(R.layout.dovomi, container, false);

    return thisfragment;
}



private class getFeed extends AsyncTask<Void, Void, Document> {



       }

    protected Document doInBackground(Void... params) {

        XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(URL); // getting XML from URL
        Document doc = parser.getDomElement(xml); // getting DOM element

        return doc;
    }

    protected void onPostExecute(Document doc) {

    ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();

    NodeList nl = doc.getElementsByTagName(KEY_TEST);
    // looping through all song nodes <song>
    for (int i = 0; i < nl.getLength(); i++) {
        // creating new HashMap
        HashMap<String, String> map = new HashMap<String, String>();
        Element e = (Element) nl.item(i);
        // adding each child node to HashMap key => value
        map.put(KEY_ID, parser.getValue(e, KEY_ID));
        map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
        map.put(KEY_Description, parser.getValue(e, KEY_Description));
        map.put(KEY_DURATION, parser.getValue(e, KEY_DURATION));
        map.put(KEY_THUMB_URL, parser.getValue(e, KEY_THUMB_URL));
        map.put(KEY_PRICE, parser.getValue(e, KEY_PRICE));
        map.put(KEY_URL, parser.getValue(e, KEY_URL));
        // adding HashList to ArrayList
        songsList.add(map);
         pDialog.dismiss();
    }



    list=(ListView)getActivity().findViewById(R.id.list);

    // Getting adapter by passing xml data ArrayList
    adapter=new LazyAdapterbeth(getActivity(), songsList);
    list.setAdapter(adapter);


    // Click event for single list row
    list.setOnItemClickListener(new OnItemClickListener() {

How do I update my view when I go from page one to page two?

how can i use instantiateItem and notifyDataSetChanged(); on this code to update view ?

  • 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-06-17T06:35:11+00:00Added an answer on June 17, 2026 at 6:35 am

    First of all your Fragments needs to return a instance of the Fragment, you can do this by adding a newInstance(Bundle args); Then you can update the Fragment depending on the postion in the ViewPager with FragmentArguments.

    public class CustomList extends SherlockListFragment{
    int fragment_position_in_viewpager = 0;
    ....
    public static CustomList newInstance(Bundle args) {
    customlist fragment = new CustomList();
    fragment.setArguments(args);
    return fragment;
    }
    ....
    
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        fragment_position_in_viewpager = getArguments().getInt("position"); 
    } 
    String[] params = {xmlURLArray[fragment_position_in_viewpager]}
    
    new getFeed().execute(params);
    
    }
    
    protected Document doInBackground(String... params) {
    
        XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(params[0]); // getting XML from URL
    ....
    
    
    
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
     ViewGroup root = (ViewGroup) inflater.inflate(
                R.layout.layout_custom_list, container, false);
    
        //initialize your widgets here
        //button = (Button) root.findViewById(R.id.button);
    
        return root;
    }
    
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    
    final int fragment_position_in_viewpager;
    if (getArguments() != null) {
        fragment_position_in_viewpager = getArguments().getInt("position"); 
    } 
    
         //Update the Fragment UI depending on the ViewPager Position.
    
    ....
    

    Then in your TestFragmentAdapter (FragmentPagerAdaper)

    ....
    @Override
    public Fragment getItem(int position) {
    
             //Return a Fragment
            //from a new Instance with FragmentArguments
                Bundle args = new Bundle();
                args.putInt("position", position);
                return CustomList.newInstance(args);
    
    //use a switch if you have different types Fragments
    //switch(position) {
        //case 0:
            //From the Fragment Constructor 
                //    return (mCustomList = new CustomList());
    ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have page named page--news.tpl.php, which i created for my news page. But after
I have page which is redirected from htaccess. now I can pass the German
Ok, I have page one(index), fully functional and working fine as is with all
I have a ListView with one TextView. List view is populated from a string
I have minimal knowledge of Javascript, but would like to use this code to
I have a 1-Wire USB adapter (that bluish one) and wanted to use it
I have a spinner getting views from a custom base adapter. The problem is
I have UTF-8 everywhere so why does Page.last.url.encoding return ASCII-8BIT? My database.yml: development: adapter:
In my small Android app, I have a ViewPager with 3 pages, each page
I have page where I load different videos.I use jw player as player if

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.