Antonis
Antonis

Reputation: 1061

Android Grouping textviews

I have a details Form with multiple textviews (label: field) that are added with a for loop. Is there a way to present some of them as a group in the UI, based on a property? e.g. Personal data or financial data?

Personal

Name: John Doe

Address: Somewhere

Phone: 0000000000

Dates
Reminder: 18/11/2011

DateFrom: 10/11/2011

DateTo: 20/11/2011

thanks in advance

Upvotes: 0

Views: 7499

Answers (3)

user849998
user849998

Reputation:

You can create a LinearLayout programatically as:

LinearLayout group1 = new LinearLayout(this);
group1.addView(myTextView1);
group1.addView(myTextView2);

in this way you can create a new view, which will have a collection of TextViews

EDIT: If you want to automate process a little more, you may consider setting tags for every TextView using:

TextView.setTag("Finances");

and then create groups by adding distinguished TextViews into LinearLayouts using:

String tag = TextView.getTag();

if(tag.equals("Finances")){
 group1.addView(TextView);
}

Upvotes: 4

Jordi Coscolla
Jordi Coscolla

Reputation: 1066

In android there isn't an standard way to agroup blocks of information... Each application use his own way.

Mine is to create a LinearLayout with an style that sets the background and font and put inside a Label with the group name.

Upvotes: 1

Hiral Vadodaria
Hiral Vadodaria

Reputation: 19250

You can differenciate them in groups by setting their background color to a specific one for particular group.

But at end,you would have to specify,which color is use for which property for user convenience!

And you can also take two linear layouts and setting different colors of them according to the category they contains TextViews of.That would also be a good solution.You can set Text on its top to specify the category.

Upvotes: 1

Related Questions