简体   繁体   中英

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 ?

您可以使用String.Format

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

Its very simple.

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

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM