Bert Steve
Bert Steve

Reputation: 41

Writing "text" and Resource ID in Android

How do I combine values from each source as mentioned say for example I want to change the titlebar value...

 page.setTitle(R.id.pagetitle) 

Combine with...

 page.setTitle("a text") 

In order to output...

 "R.id.pagetitle: a text" (note the " : ") 

What is used in Java to connect these values like " . " in PHP or " + " in JavaScript?

Upvotes: 1

Views: 82

Answers (2)

MysticMagicϡ
MysticMagicϡ

Reputation: 28823

Its very simple.

String titleText = firstText.concat("a text");
page.setTitle(titleText);

Hope it helps.

Upvotes: 1

MrK
MrK

Reputation: 662

You can use String.Format

String myString = String.Format("%s: a title", getText(R.id.pagetitle));

Upvotes: 2

Related Questions