Image For Imagebutton Doesn't Change As Intended
My goal here is to change an Image from an ImageButton(ibChamp). package com.example.custombuilds; import android.app.Activity; import android.content.Context; import android.cont
Solution 1:
You are inflating "ibChamp" in onClick. That creates a new ImageButton. You will not see it until you use "addView" from the parent.
You can add your XML, but you need to get a reference to an existing button in Activity in order to change it. Or else add the new button and remove an old one...
In other words, change this:
LayoutInflaterlayoutInflater= (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Viewview= layoutInflater.inflate(R.layout.create_build_page, null);
ImageButtonimg= (ImageButton) view.findViewById(R.id.ibChamp);
to this:
ImageButtonimg= (ImageButton)findViewById(R.id.ibChamp);
And it will probably do what you want.
Solution 2:
you need to call addView() for this inflated view
Viewview= layoutInflater.inflate(R.layout.create_build_page, null);
Post a Comment for "Image For Imagebutton Doesn't Change As Intended"