To load a new activity when an image is clicked.

  • Replies:3
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Oct 21, 2015 7:27:13 AM via Website

Hi,
Is there anyway to load a new activiy through an image rather than imagebutton???

  • Forum posts: 26

Oct 22, 2015 4:30:07 PM via Website

absolutely there is.. in the xml for your image view add an onclick parameter.

android:onClick="onClick"

now in your actual code you will have to make a little routine called onclick that does the lifting.. like this.

// get the button view
fashionImg = (ImageView) getView().findViewById(R.id.selectone);
// set a onclick listener for when the button gets clicked
fashionImg.setOnClickListener(new OnClickListener() {
// Start new activity
public void onClick(View v) {
Intent mainIntent = new Intent(getActivity(),
ActivityToLoadActivity.class);
startActivity(mainIntent);
}
});

keep in mind you will have to adjust the onClick to reflect exactly what you want to do. this one loads a new activity

-MunkeeBonez

  • Forum posts: 208

Oct 23, 2015 7:24:58 AM via Website

Almost every wodget control has onlclick action. You can perform this action.

  • Forum posts: 2

Oct 25, 2015 7:39:59 AM via Website

some time its not show such a things