简体   繁体   English

如何用另一种类型的二维数组的维度初始化一种类型的二维数组

[英]How do you initialize a 2d array of one type with the dimensions of a 2d array of another type

Nooby question I know but I Have an Integer[][] array initialized to Integer[X][Y] and a Button[][] array, How do I also initialize the Button array to also be Button[X][Y]. Nooby 问题我知道,但我有一个 Integer[][] 数组初始化为 Integer[X][Y] 和一个 Button[][] 数组,我如何也将 Button 数组初始化为 Button[X][Y] . I tried using a double for loop but I feel like I am missing an easier way.我尝试使用双 for 循环,但我觉得我错过了一种更简单的方法。

Button buttons[][] = {
                {findViewById(R.id.button00), findViewById(R.id.button01)},
                {findViewById(R.id.button10), findViewById(R.id.button11)}
        };

This code works good for me这段代码对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM