Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I write java code in android xml layout or string values files?

I want to know if it is possible to write java code in android XML layout or string values files?

I mean something like this:

<string name="hello">Utilities.doSomething("Hello World, ActMain!")</string>
<string name="app_name">insurance</string>

like image 565
Bobs Avatar asked Mar 12 '26 13:03

Bobs


1 Answers

Running code from strings.xml can be possible in the following way(Not tested,but a high level idea of doing it) 1.Get the string from strings.xml using R.string.* where * is the name of your string.

2.Use any of the expressions evaluation library to run it.

Again this a very high level idea.You will have to figure out how to do that your self.

Check the Jel library for it

Or check this list of evaluation libraries

like image 70
Mukund Samant Avatar answered Mar 14 '26 02:03

Mukund Samant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!