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

  • Home
  • SEARCH
  • 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 8906339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:37:41+00:00 2026-06-15T02:37:41+00:00

I have a listview contain items Apple, Banana, Orange …in second screen activity when

  • 0

I have a listview contain items Apple, Banana, Orange …in second screen activity
when I click on particular item on Apple it navigates to Details screen

here output has to appear like by clicking on –> Apple ..if I swipe page then banana and for next swipe Orange

Apple–>Banana–>Orange

If I click on Banana –>then it has to appear like Banana then left swipe Apple ..and for right swipe…Orange.

So which item I clicked on(Banana) listview in second screen it has to appear on details screen and for left swipe previous list item and for right swipe next item in the list.

Banana–>for left swipe Apple
–>for right swipe Orange

If I click on Orange –>then it has to appear like Orange then left swipe Banana ..and for next left swipe…Orange.
Banana

Orange–>for left swipe Banana—>for next left swipe–>Apple

but am getting output like Apple–>Banana–>Orange for all the cases of each item clicked on the listview….

public class SecondScreen extends Activity {
ListView listView;
LayoutInflater lay;
    MyApplication app; 
protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState); 

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.second);

app = ((MyApplication) getApplicationContext());

    listView = (ListView) findViewById(R.id.yearlistss);
        listView.setAdapter(new MyAdapter(SecondScreen.this,app.totalvalue));
    listView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> arg0, View arg1, final int arg2,
                long arg3) {        


            Intent detailIntent =new Intent(SecondScreen.this, Details.class);          

            startActivity(detailIntent);            
        }
    });

    }


public class MyAdapter extends BaseAdapter {

            Context context = null;

            private ArrayList<String> temperList1;


            public MyAdapter(SecondScreen secondScreen, ArrayList<String> totalvalue) {

                this.temperList1 = totalvalue;

            }

            public int getCount() {
                // TODO Auto-generated method stub
                return temperList.size();


            }

            public Object getItem(int position) {
                // TODO Auto-generated method stub
                return temperList;
            }

            public long getItemId(int position) {
                // TODO Auto-generated method stub
                return position;
            }

            public View getView(int position, View convertView, ViewGroup parent) {
                // TODO Auto-generated method stub

                View layout = null;


                TextView totalval = null;


                if (convertView == null) {

                    lay = LayoutInflater.from(getApplicationContext());
                    layout = lay.inflate(R.layout.secondlist, null);


                    totalval = (TextView) layout.findViewById(R.id.total);                  


                } else {
                    layout = convertView;
                }                       

                 totalval.setText("" + temperList1.get(position));

                return layout;
    }

        }





}









public class MyApplication extends Application {

    ArrayList<String> totalvalue  = new ArrayList<String>();

}







public class Details extends FragmentActivity{

    MyApplication app;
    ViewPager pager;
  MyFragmentPagerAdapter pagerAdapter;     
 public static int position ;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.detail);    
    app = ((MyApplication) getApplicationContext());
    pager = (ViewPager) findViewById(R.id.pager);

    FragmentManager fm = getSupportFragmentManager();      
    pagerAdapter = new MyFragmentPagerAdapter(fm,app.totalvalue);   
      pager.setAdapter(pagerAdapter);

  }



public static class MyFragmentPagerAdapter extends FragmentPagerAdapter {


    private final  ArrayList<String> temperList;



    public MyFragmentPagerAdapter(FragmentManager fm, ArrayList<String> totalvalue ) {
         super(fm);
         this.temperList = totalvalue;
    }


    public Fragment getItem(int position) {

        return ThingFragment.newInstance((temperList.get(position)));
    }

    @Override
    public int getCount(){

    return temperList.size();

    }

     private static class ThingFragment extends Fragment {       
            private String name1;
         static ThingFragment newInstance(String string ) {

                ThingFragment f = new ThingFragment();
                Bundle args = new Bundle();

        args.putString("name",string );
                f.setArguments(args);

                return f;
            }



            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                name1 = getArguments().getString("name");
            }

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

                View v = inflater.inflate(R.layout.myfragment_layout, container, false);
                TextView t = (TextView)v.findViewById(R.id.prodcutt);
                t.setText(""+ name1);
                return v;
        }

    }

}


}
  • 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-15T02:37:42+00:00Added an answer on June 15, 2026 at 2:37 am

    In the OnItemClickListener for your list of fruits you should pass the position of the selected fruit in the Intent so you can know in the details activity which fruit was clicked, something like this:

    Intent detailIntent =new Intent(SecondScreen.this, Details.class);          
    detailIntent.putExtra("fruitPosition", arg2);
    startActivity(detailIntent); 
    

    Then in your details activity you would retrieve that number and position the ViewPager accordingly:

    setContentView(R.layout.detail);    
    app = ((MyApplication) getApplicationContext());
    pager = (ViewPager) findViewById(R.id.pager);
    FragmentManager fm = getSupportFragmentManager();      
    pagerAdapter = new MyFragmentPagerAdapter(fm,app.totalvalue);   
    pager.setAdapter(pagerAdapter);
    Intent startIntent = getIntent();
    int fruitPosition = startIntent.getIntExtra("fruitPosition", 0);
    pager.setCurrentItem(fruitPosition);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with listview which list item contain a checkbox. When i
I have a listview where each list item can contain 1 or more clickable
I have created a ListView which contains a list of items. Each item in
I have a ListView which can contain any number of items. When it uses
I have a listview that can contain up to roughly 2,000 listview items I
I have one function which is called on list item Click and list items
I have a ListView which might contains a lot of items, so it is
I have create a listview of Contact numbers , the list item contains the
I have a listview that contain several EditTexts created dynamically according to the number
I have a listview that is loaded with a list of objects that contain

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.