--stacktrace
我想将视图ID转换为 public void buttonA1(View view) {
int[] board = {R.id.A1, R.id.A2, R.id.A3, R.id.B1, R.id.B2, R.id.B3, R.id.C1, R.id.C2, R.id.C3};
int i=view.getId().intValue; //even this one didn't work
}
,以便我可以在数组中查找,如图所示。我怎么做?
我尝试了类似int
之类的东西,但它一直说数组没有int posNew = Arrays.asList(board).indexOf(view.getId())
类型的对象。
我甚至尝试了这个Integer
,但它仍然没有用。
答案 0 :(得分:1)
int i=view.getId();
会将视图ID作为整数值返回。
并使用排序逻辑来检查整数数组中id的位置。
答案 1 :(得分:0)
我不知道你为什么要将它们添加到数组中,但这样可以正常工作
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce GTX 770"
CUDA Driver Version / Runtime Version 6.0 / 5.5
CUDA Capability Major/Minor version number: 3.0
Total amount of global memory: 2047 MBytes (2146762752 bytes)
( 8) Multiprocessors, (192) CUDA Cores/MP: 1536 CUDA Cores
GPU Clock rate: 1084 MHz (1.08 GHz)
Memory Clock rate: 3505 Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 524288 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 1 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device PCI Bus ID / PCI location ID: 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 6.0, CUDA Runtime Version = 5.5, NumDevs = 1, Device0 = GeForce GTX 770
Result = PASS
ArrayList需要对象,所以将原语int包装在Integer对象中 所以
ArrayList<Integer>arrayList;
arrayList = new ArrayList<>();
arrayList.add(new Integer(R.id.button));
arrayList.add(new Integer(R.id.button1));
.
.
.
答案 2 :(得分:0)
已查看了ID IS 整数。无需转换任何东西。如果您想将int
转换为Integer
,请:
Integer viewId = new Integer(view.getId());
可以胜任。
答案 3 :(得分:0)
per documentation,getId()
方法已返回int。不需要转换或方法