package com.handstudio.android.healthup.manager;
import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.handstudio.android.healthup.R;
public class CircleIndicatorManager {
private ImageView[] imgCircle;
private Context context;
public CircleIndicatorManager(Context context){
this.context = context;
}
/**
* 기본 Circle 생성
* @param context
* @param layout Circle 이 표시될 레이아웃
* @param count Circle 의 개수
*/
public void createDotPanel(LinearLayout layout, int count){
imgCircle = new ImageView[count];
layout.removeAllViews();
for(int i=0;i<count;i++){
imgCircle[i] = new ImageView(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.leftMargin= 10;
params.rightMargin= 10;
params.gravity = Gravity.CENTER;
imgCircle[i].setLayoutParams(params);
imgCircle[i].setImageResource(R.drawable.img_circle_indicator_default);
layout.addView(imgCircle[i]);
}
}
/**
* Circle 선택 이미지 변경
* @param position Circle 번째
*/
public void selectDot(int position){
for(int i=0;i<imgCircle.length;i++){
if(i==position) imgCircle[i].setImageResource(R.drawable.img_circle_indicator_selected);
else imgCircle[i].setImageResource(R.drawable.img_circle_indicator_default);
}
}
}
|