我有四个使用4个不同阵列的ArrayAdapters
console.log(JSON.stringify(myJson))
我有两个微调器
# Database setup
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: storage-camera
labels:
group: camera
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-ssd
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: camera-pv
labels:
group: camera
spec:
storageClassName: db-camera
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
storageClassName: storage-camera
---
# Service setup
apiVersion: v1
kind: Service
metadata:
name: camera-service
labels:
group: camera
spec:
ports:
- port: 50052
targetPort: 50052
selector:
group: camera
tier: service
type: LoadBalancer
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: camera-service
labels:
group: camera
tier: service
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
minReadySeconds: 60
template:
metadata:
labels:
group: camera
tier: service
spec:
containers:
- image: asia.gcr.io/test/db-camera:latest
name: db-camera
env:
- name : MYSQL_ROOT_PASSWORD
value : root
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: camera-persistent-storage
mountPath: /var/lib/mysql
- name: camera-service
image: asia.gcr.io/test/camera-service:latest
env:
- name : DB_HOST
value : "localhost"
- name : DB_PORT
value : "3306"
- name : DB_NAME
value : "camera"
- name : DB_ROOT_PASS
value : "password"
ports:
- name: http-cam
containerPort: 50052
volumes:
- name: camera-persistent-storage
persistentVolumeClaim:
claimName: camera-pv
restartPolicy: Always
在单击的按钮上,adapter1 = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_spinner_item,getResources().getStringArray( R.array.array1) );
adapter2 = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_spinner_item,getResources().getStringArray(R.array. array2));
adapter3 = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_spinner_item,getResources().getStringArray(R.array. array3));
adapter4 = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_spinner_item,getResources().getStringArray(R.array. array4));
和spinnerFrom = findViewById(R.id.unit_From_spinner)
spinnertTo = findViewById(R.id.unit_To_spinner);
填充代码中指定的适配器。
我的主要想法是在项目中编写如下内容:
spinnerFrom
问题:如何获取当前使用的适配器并通过spinnertTo
和{指定其名称(if (spinnerFrom use adapter 1 or adapter 2 || spinnerTo use adapter 1 or adapter 2){
some code
}
else if (spinnerFrom use adapter 3 or adapter 4 || spinnerTO use adapter 3 or adapter 4){
some code
}
/ adapter1
/ adapter2
/ adapter3
) {1}}旋转器并使if-else(或者我应该使用adapter4
)结构吗?
谢谢!
答案 0 :(得分:0)
一个简单的相等检查应该起作用:
if (spinner.getAdapter() == adapterInstance) //etc
通常,您不想在Java中执行此操作,因为它比较实例而不是值,但是在这种情况下,它应该做您需要的操作,即比较实例。