If you think the Android project baracus-framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package net.mantucon.baracus.ui;
//fromwww.java2s.comimport android.content.Context;
import android.util.AttributeSet;
import android.widget.Spinner;
import net.mantucon.baracus.context.BaracusApplicationContext;
import net.mantucon.baracus.util.Logger;
import net.mantucon.baracus.validation.ConstrainedView;
/**
* Constraineable Spinner
*/publicclass ConstrainedSpinner extends Spinner implements ConstrainedView<Object> {
// comma seperated list of validators
private String validators;
public ConstrainedSpinner(Context context) {
super(context);
}
public ConstrainedSpinner(Context context, int mode) {
super(context, mode);
}
public ConstrainedSpinner(Context context, AttributeSet attrs) {
super(context, attrs);
parseAttribs(attrs);
}
public ConstrainedSpinner(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
parseAttribs(attrs);
}
public ConstrainedSpinner(Context context, AttributeSet attrs, int defStyle, int mode) {
super(context, attrs, defStyle, mode);
parseAttribs(attrs);
}
@Override
public Object getCurrentValue() {
return getSelectedItem();
}
@Override
public String getValidators() {
return validators;
}
privatevoid parseAttribs(AttributeSet attributeSet) {
Logger log = new Logger(this.getClass());
log.info("---------------------------------");
int i = 0;
boolean cont = true;
while (i < attributeSet.getAttributeCount() && cont) {
log.info("$1 -> $2 -> $3", attributeSet.getAttributeName(i), attributeSet.getAttributeValue(i), attributeSet.getPositionDescription());
if ("validatedSpinnerBy".equals(attributeSet.getAttributeName(i))) {
this.validators = attributeSet.getAttributeValue(i);
log.info("VALIDATORS HAS BEEN SET TO $1", validators);
cont = false;
}
++i;
}
BaracusApplicationContext.verifyValidators(validators);
log.info("---------------------------------");
}
}