我正在尝试存储一个名称以及特定视图的相应左,右,上,下尺寸。我尝试使用hashmap仅存储(键,值)。请有人告诉我应该使用哪个集合来满足我的要求。
for (int i = 0; i < numberOfFaceDetected; i++) {
android.media.FaceDetector.Face face = myFace[i];
Log.i("FACE","FACE TAGGING : "+myFace[i].toString());
String facename = myFace[i].toString();
PointF myMidPoint = new PointF();
face.getMidPoint(myMidPoint);
myEyesDistance = face.eyesDistance();
dx = (int) (myMidPoint.x - myEyesDistance);
dy = (int) (myMidPoint.y - myEyesDistance);
dz = (int) (myMidPoint.x + myEyesDistance);
dt = (int) (myMidPoint.y + myEyesDistance);
//here i want to store facename,dx,dy,dz,dt values in same collection
canvas.drawRect((int) dx, dy, dz, dt, myPaint);
}
最佳答案
Map<YourKeyClass, YourValuesClass>
怎么样?
例如。
class YourValuesClass
{
int dx, dy, dz, dt;
// getters and setters
// ...
}
Map<String,YourValueClass> map = new HashMap<String,YourValueClass>();
干杯,