4

I want to create a custom view with some text and two buttons all on one line. I need to be able to add multiple (any number) of these views to an existing layout dynamically (needs to be able to scroll). I want to pass a custom object to the view and set the text and buttons. I need access to the button event handlers from the activity. I've looked a little into custom views but I'm still at a loss for how to do what I want. I'm used to .NET custom controls, and I'm looking for the same effect. Any help or example code would be greatly appreciated.

1

2 Answers 2

2

What you want is custom compound view. You should write you own class (usually extending one of the layouts) and whole behavior, inflate the layout the way you want etc.

More of it: http://developer.android.com/guide/topics/ui/custom-components.html

This one helped me a lot too: http://javatechig.com/android/creating-custom-and-compound-views-in-android-tutorial

Sign up to request clarification or add additional context in comments.

Comments

0

If you use list activity or list fragment, you will automatically have the many features you have asked for. You only need to create a adapter class for your listview. You can define your layout for your row view(buttons, text etc..) Try to look at the examples on the web for cusom adapter and lists.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.