如何从 SecondActivity 中的 FirstActivity 调用public void function?
.outer {
display: inline-block;
position: relative;
padding-left: 2.5em;
}
.inner {
display: block;
position: absolute;
margin: auto;
top: 0;
bottom: 0;
left: 0;
}
// FirstActivity
public void thisFunction(){
// do something
// do something
}
中的
Second Activity
但返回错误:
if(x){
FirstActivity.thisFunction();
}
答案 0 :(得分:0)
静态函数是类的函数,不依赖于该类的任何对象
Class.staticFunction()(无需实例化),你可以随处调用它
public static void thisFunction(){
// do something
// do something
}
然后在SecondActivity中:
FirstActivity.thisFunctions();