我在 A 类中有一个名为 Floors 的数组,它包含类似于以下内容的值:
List<Point> manualpoint = new ArrayList<Point>();
int[] manualpointx = {135,200,300,155,235,300};
假设我希望将这些值传递给 B 类,假设 B 类已经声明了一个父类(super class) View
public class DrawView extends View implements OnTouchListener {
@Override
public void onDraw(Canvas canvas) {
//pass the values into this class
}
}
如何将值从 A 类传递到 B 类?
最佳答案
在 Activity 之间传递数据
//to pass array use
intent.putExtra("intarray", manualpointx);
// to pass list of point use
intent.putParcelableArrayListExtra("bundle", (ArrayList<? extends Parcelable>) manualpoint);
对于类(class)
create public getter methods to return the values and call those methods from any class where you want to get the values
关于java - 将数组从 A 类传递到 B 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8738017/