Toast With Image

Button toastwitimage;

@Override    public void onCreate(Bundle savedInstanceState) {                           super.onCreate(savedInstanceState);                                                     setContentView(R.layout.main);

toastwitimage=(Button)findViewById(R.id.twibtn);                      toastwitimage.setOnClickListener(new OnClickListener() {                       @Override

public void onClick(View v) {

Toast toast = Toast.makeText(getApplicationContext(), “Toast with image!”,1000);

toast.setGravity(Gravity.CENTER, 0, 0);

LinearLayout toastView = (LinearLayout) toast.getView(); ImageView imageCodeProject = new ImageView(getApplicationContext()); imageCodeProject.setImageResource(R.drawable.alien); toastView.addView(imageCodeProject, 0); toast.show();

}

});

}


Need more help?

Hi there, was your problem or query resolved? If not & need more assistance, please do reach out to us at info@nanostuffs.com, we'll be more than delighted to help. Nanostuffs has 7+ years of extensive Salesforce & iOS/Android experience.
Holler Box