我想动态地从其他类中获取一些值,例如:

huangapple go评论92阅读模式
英文:

I want to get some value from other class dynamicly for ex:

问题

 public class Data{
  public class Friend{
    public int[] jane = {something};
    public int[] frank = {something};
    public int[] john = {something};
  }
}

我想在其他类中像这样使用这个变量:

class GetData {
  int[] getName = Data.classname.friendName;
}
英文:

My code

 public class Data{
  Public class Friend{
public int[] jane = {somthing};
public int[] frank = {somthing};
public int[] john = {somthing};
}}

I wanna use this variable in other class like this:

class GetData{
int[] getName = Data."className"."friendName";
}

</details>


# 答案1
**得分**: 0

```java
public class GetData{
    int[] getName = Data."className"."friendName";
}

// 将 getdata 类继承到你的第二个类。

public class MainActivity extends AppCompatActivity implement GetData{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}
英文:
public class GetData{
int[] getName = Data.&quot;className&quot;.&quot;friendName&quot;;
}

inherit the getdata class to your second class.

public class MainActivity extends AppCompatActivity implement GetData{
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

}

答案2

得分: 0

@安卓远程控制,那么,您试图实现什么,您在这里所指的动态是什么意思?请明确您的问题。

英文:

@android remote control, So, what you are trying to achieve, what do you mean by dynamic here? please be clear with your question.

huangapple
  • 本文由 发表于 2020年4月6日 02:00:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/61047058.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定