I want to create a custom view (extends View) which contains an image and a text.
Is it possible to set an listener just for image if i use canvas.drawBitmap(imageBitmap, ...) method?
Thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want your view just to show an image and a text, why not create a specific layout in your XML file and use
setContentViewto display the view?If thats what you were looking for, I think that is the easiest approach. XML example coming soon.
Here is the contents of my personal view to display my main application, just to demonstrate how I can switch view’s, your view would be different including a
TextViewand anImageView.dblist.xml inside of
res/layoutfolder.This contents display my database results onto a
SpinnerI can call that view by using:
And if I want to return to my main layout, I can switch the view by calling
EDIT:
You can manipulate the view you are working with programmatically by using
findViewByIdmethod. Let’s use my dblist.xml file as an example, notice that myListViewhas an id oflist. So I would call:With corresponds to that layout, so whenever I want to change anything to my XML file, I would reference
myListuse methods and callbacks to meet my needs.I hope this helps.