Moises Jimenez
Moises Jimenez

Reputation: 1962

Custom UI element containing several TextViews

Right now I'm trying to figure out how to create a custom UI component, say custom view. I have a ListView and I want to be able to add elements that contain three TextViews but are atomic, so to speak and have a defined layout. I'm really not sure how to do this and the only idea I have are custom views. Am I on the right track?

Upvotes: 2

Views: 246

Answers (2)

Kritz
Kritz

Reputation: 7301

You're on the right track. You can easily accomplish this with a SimpleCursorAdapter if your data is in a cursor.

Use the following:

SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, R.layout.customview,cursor, from_columns, to_customviewfields)

and then set the adapter to the listview:

setListAdapter(mAdapter);

Upvotes: 0

iTurki
iTurki

Reputation: 16398

I think you don't need to follow the CustomView road. You can customize how you want your ListView's row look like. You can add images, multiple textView and whatever you want.

Here is a good tutorial that make the list row look like this: enter image description here

Upvotes: 6

Related Questions