1. Are you ready for the Galaxy S20? Here is everything we know so far!

setOnPageChangeListener - button dont get event

Discussion in 'Android Development' started by trubar, Aug 19, 2012.

  1. trubar

    trubar Lurker
    Thread Starter

    Hello,

    i have one problem. i have viewpager on activity_start. When I change myPager.setCurrentItem(0) there should button btnStisni get event onClick, but it dont. i even set myPager.setCurrentItem(1) so that schould start event setOnPageChangeListener. Any idea why? Code is below.

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_start);



    final xsPagerAdapter adapter = new xsPagerAdapter();
    myPager = (ViewPager) findViewById(R.id.xspanelpager);
    myPager.setAdapter(adapter);
    myPager.setCurrentItem(1);


    myPager.setOnPageChangeListener(new OnPageChangeListener() {

    public void onPageSelected(int position) {
    // TODO Auto-generated method stub

    iExPosition = myPager.getCurrentItem();

    switch (position) {
    case 0:
    btnStisni = (Button)findViewById(R.id.btnStisni1);
    btnStisni.setOnClickListener(new View.OnClickListener() {


    public void onClick(View v) {
    myPager.setCurrentItem(1);
    }
    });

    break;
    case 1:

    break;
    case 2:

    break;
    case 3:
    myPager.setCurrentItem(0);
    break;
    }

    }

    myPager.setCurrentItem(0);
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...