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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:11:45+00:00 2026-06-10T03:11:45+00:00

I am Working on the quiz application . Here I am using Viewpager indicator

  • 0

I am Working on the quiz application. Here I am using Viewpager indicator.In this I have implemented listview with radio button.

My question is,How can I got the diffent values for listviews on every page of the viewpager.

I tried Google,But I don’t find solution. Please help me. Thank You

see below Images:

enter image description here
enter image description here

Check My code :

 class PagerAdapter extends FragmentPagerAdapter implements SwipeyTabsAdapter{

    public final String[] list = new String[]
        {"Operating System", "Product Of Google", "Both Above", "None of above"}
; 

    private final Context mContext;

    public PagerAdapter(Context context, FragmentManager fm) {
        super(fm);

        this.mContext = context;
    }


    @Override
    public Fragment getItem(int pos) {

        return ItemFragment.newInstance(QUES[pos]);
        //return ItemFragment.newInstance(QUES[pos % TITLES.length]);

    }

    @Override
    public int getCount() {
        return TITLES.length;
    }

    public TextView getTab(final int position, SwipeyTabs root) {
        TextView view = (TextView) LayoutInflater.from(mContext).inflate(
                R.layout.swipey_tab_indicator, root, false);
        view.setText(TITLES[position]);
        view.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                mViewPager.setCurrentItem(position);

            }
        });
        return view;
    }


}

public static class ItemFragment extends  Fragment{

    static ItemFragment newInstance(String title) {
        ItemFragment f = new ItemFragment();

        // Supply num input as an argument.
        Bundle args = new Bundle();

        args.putString("title",title);
        f.setArguments(args);

        System.out.println("value of the title : ================>"+title);
        return f;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.view_question, container, false);
        View tv = v.findViewById(R.id.text);
        final View listvw = v.findViewById(R.id.listview);

         final String title = getArguments().getString("title");
         ((TextView)tv).setText(title);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_single_choice, list);
        ((ListView) listvw).setAdapter(adapter);
        ((ListView) listvw).setChoiceMode(ListView.CHOICE_MODE_SINGLE);

        return v;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);


    }

    public void onListItemClick(ListView l, View v, int position, long id) {

        Log.i("FragmentList", "Item clicked: " + id);

    }
}
  • 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-10T03:11:46+00:00Added an answer on June 10, 2026 at 3:11 am

    Try this One :

    First of all initialize the listvalue as per display below

    /*public final String[] list = new String[]
        {"Operating System", "Product Of Google", "Both Above", "None of above"};*/
    
    
    public static final String[] listArray = new String[]
            {
            "Operating System,Product Of Google,Both Above,None of above",
            "os,Google,Both,None",
            "Operating System,Product Of Google,Both Above,None of above",
            "os,Google,Both,None",
            "Operating System,Product Of Google,Both Above,None of above",
            "os,Google,Both,None",
            "Operating System,Product Of Google,Both Above,None of above",
            "os,Google,Both,None"};
    

    Add the parameter into getItem listArray[pos] Like :

    @Override
        public Fragment getItem(int pos) {
    
            return ItemFragment.newInstance(QUES[pos],listArray[pos]);
    
        }
    

    And changes into ItemFragment class Like :

    static ItemFragment newInstance(String title,String arrayList) {
            ItemFragment f = new ItemFragment();
    
            // Supply num input as an argument.
            Bundle args = new Bundle();
    
            args.putString("title",title);
            args.putString("listvalues",arrayList);
            f.setArguments(args);
    
            return f;
        }
    
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.view_question, container, false);
            View tv = v.findViewById(R.id.text);
    
            final String title = getArguments().getString("title");
            final String  Listvalues = getArguments().getString("listvalues");
    
    
            String[] arr=Listvalues.split(",");
    
            System.out.println("Array :"+arr.length);
            for(int i=0;i<arr.length;i++)
            {
    
              //  System.out.println("array"+i+":========================>"+arr[i]);
            } 
    
             ((TextView)tv).setText(title);
    
            final View listvw = v.findViewById(R.id.listview);
    
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_single_choice, arr);
            ((ListView) listvw).setAdapter(adapter);
            ((ListView) listvw).setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    
            return v;
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on quiz application . For each question there are multiple answers
I have a basic quiz/survey type application I'm working on, and I'd like to
I am working on quiz application . For each question there are multiple options
I am working on a quiz application. In that I am displaying the question
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
I'm trying to grade a quiz application I would like to make. I have
I have little quiz game I've working on and am tracking correct answers. I
I am working on quiz application. It contains 2 types of tests. The first
I'm working on a java quiz application. The application will consist of 20 questions
Im using swing in java to make a quiz for my coursework. I have

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.