Android - importing Java class into action
I have a java class called Constants filled with variables. And currently, if I want to use this variable in an activity, I have to use it like this.
Constants.variable = "blah blah";
Is there a way to import my constants class into my activity so that I can just use it like a regular variable like this
variable = "blah blah";
I tried
import.com.myname.appname.Constants;
but it doesn't work.
Thanks for the help at adavance :)
given Constants.variable - static variable
import static com.myname.appname.Constant.*;
this will import all your static variables in the current namespace only static variable
import static com.myname.appname.Constant.variable;
now you can use the variable like a regular variable
source to share
Is there a way to import my constants class into my activity so that I can just use it like a regular variable like this
I don't think that's not what it is import
for.
See this SO question: Importance of Import Statement in Java File
source to share