• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Pressing a Button Changes an Image

I've been trying to figure this out for almost an entire day now. So I figure I'll just ask for help. I'm building a comic strip styled application and I'm trying to make "previous page" and "next page" buttons.

Right now, I have an image that spans 500 x 200 (not really, but it works). Over top of that image, I have two buttons equal to 50% of each side. When you click the left button, I want it to change the image to whatever-x. When you click the right button, I want it to change the image to whatever-y.

I have tried 20 tutorials.. and none of them are working for me. I just want it to work. :( Any help would be greatly appreciated. Thanks.
 
If you are just using an ImageView for the image, just use the setImageBackground() method (im pretty sure thats the method name. Havent used it in a while and on my phone, so cant easily double check).
 
Code:
        final ImageButton nextpage;
        ImageView page_100;

         nextpage = (ImageButton) findViewById(R.id.nextpage);

        nextpage.setOnClickListener( new OnClickListener(){
            public void onClick(View v){
                nextpage.setBackgroundResource(R.drawable.page_101);
            }
        });

I'm using this.. and I don't have any errors. But when the emulator loads, it crashes.
 
Back
Top Bottom