【问题标题】:How should I be storing these values?我应该如何存储这些值?
【发布时间】:2014-04-11 19:32:28
【问题描述】:

我问这个问题是因为我在质疑编写应用程序的最佳方式。我有一些我不确定如何组织的数据 - 练习。每个练习都有名称、肌肉群、指令和图像编号。

这些练习是静态的,不会改变。我考虑过开设一个运动课,但这是否矫枉过正?这些可以很容易地以另一种方式存储和操作吗?我真的不确定如何处理这个问题,我部分知道这是我的理解,但除了显示之外,我不需要这些练习来在应用程序中做任何事情。

感谢您的帮助。

【问题讨论】:

  • 你必须更具体一点,你的问题中的一个实际例子会有所帮助。
  • 不知道如何给出一个实际的例子?除了,例如,这里有一个练习:肩部按压,肌肉 = 肩膀,说明 = 设置为舒适的重量,按压到顶部并轻轻放下,图像编号 = 0..

标签: java android eclipse oop adt


【解决方案1】:

如果数据是真正的静态数据并且您并没有太多,只需将其存储在 Application 类中的 Array 中:

public static final Exercise[] EXERCISES = {
  new Exercise("Shoulder Press", "shoulders", "set to comfortable weight, press to the top and gently bring down", 0),
  new Exercise("Shoulder Press", "shoulders", "set to comfortable weight, press to the top and gently bring down", 0)
};

public class Exercise {
  String name;
  String muscleWorked;
  int imageNumber;

 ...
}

【讨论】:

    猜你喜欢
    • 2013-06-27
    • 2018-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多