FORUMS
Remove All Ads from XDA

3 actions for 1 button

1 posts
Thanks Meter: 0
 
By Arzacks, Junior Member on 4th August 2018, 04:50 PM
Post Reply Email Thread
Hello !
I'm doing a small personal project with slides and all that, i'm having trouble creating a button with 3 actions depending on witch slide i'm on. I know how to put a different text in my 3 different slides but can't manage to make my buttons work.
Please help !

Code:
public class SliderAdapter extends PagerAdapter {

    Context context;
    LayoutInflater layoutInflater;
    Button slide_btn;

    public SliderAdapter(Context context) {
        this.context = context;
    }

    public int[] slide_images = {
            R.drawable.small,
            R.drawable.medium,
            R.drawable.big
    };

    public String[] slide_headings = {
            "PUSSY",
            "OKAY",
            "WARRIOR"
    };

    public String[] slide_descs = {
            "tutu",
            "toto",
            "tata"
    };

    public Button[] getSlide_btn = {
        //action1,
        //action2,
        //action3
    };

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

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object o) {
        return view == (RelativeLayout) o;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        layoutInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
        View view = layoutInflater.inflate(R.layout.slide_layout, container, false);
        ImageView slideImageView = (ImageView) view.findViewById(R.id.slide_image);
        TextView slideHeading = (TextView) view.findViewById(R.id.slide_heading);

        slideImageView.setImageResource(slide_images[position]);
        slideHeading.setText(slide_headings[position]);

        container.addView(view);

        return view;
    }

    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((RelativeLayout)object);
    }
}
I'll take any advice ! Thx !
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes