You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<com.james602152002.floatinglabelspinner.FloatingLabelSpinner
//floating label and hint text color
app:j_fls_textColorHint="@android:color/holo_orange_light"
//divider color
app:j_fls_colorHighlight="#0000FF"
//error color
app:j_fls_colorError="#0000FF"
//floating label text
app:j_fls_hint="label"
//thickness of divider
app:j_fls_thickness="2dp"
//horizontal margin of label
app: j_fls_label_horizontal_margin="2dp"
//vertical margin of label
app: j_fls_label_vertical_margin="2dp"
//horizontal margin of error text
app: j_fls_error_horizontal_margin="2dp"
//vertical margin of error text
app: j_fls_error_vertical_margin="2dp"
//floating label text size
app: j_fls_label_textSize="14sp"
//hint text size
app:j_fls_hint_textSize="20sp"
//error text size
app:j_fls_error_textSize="14sp"
//header of drop down hint view
app:j_fls_dropDownHintView="@layout/header"
//float animation duration(unit:ms)
app:j_fls_float_anim_duration="800"
//scrolling text animation duration(unit:ms)
app:j_fls_error_anim_duration="8000"
//open recursive mode(false to close)
app:j_fls_recursive="true"/>
Method
//floating label text sizesetLabel_text_size(floatlabel_text_size);
//hint text sizesetHint_text_size(floathint_text_size);
//error text sizesetError_text_size(floaterror_text_size);
//thichness of dividersetThickness(intthickness);
//divider colorsetHighlight_color(intcolor);
//hint text colorsetHint_text_color(intcolor);
//error colorsetError_color(intcolor);
//set error text horizontal and vertical marginsetErrorMargin(inthorizontal_margin, intvertical_margin);
//set float label text and hint text(Support ForegroundColorSpan)spinner.setHint(CharSequencehint);
//set drop down hint view headerspinner.setDropDownHintView(Viewview);
//set error text(null for cancel error status)setError(Stringerror);
//set float animation duration(unit:ms)setAnimDuration(shortduration)
//set scrolling text animation duration(unit:ms)setErrorAnimDuration(shortduration)
//set recursive mode, if you have many level data to fetch , you can set it true.setRecursive_mode(booleanrecursive_mode)
//dismiss dialog while recursive modedismiss()
//notify datasetchanged while recursive modenotifyDataSetChanged()
Demonstration
Cache
publicclassMainActivityextendsAppCompatActivityimplementsView.OnClickListener {
privateFloatingLabelSpinnerspinner;
privateList<String> data = newArrayList<>();
Init view
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner = findViewById(R.id.spinner);
finalintscreen_width = getResources().getDisplayMetrics().widthPixels;
finalfloatlabel_text_size = screen_width / 40;
finalfloathint_text_size = screen_width / 30;
finalshortthickness = (short) (screen_width / 250);
spinner.setLabel_text_size(label_text_size);
spinner.setHint_text_size(hint_text_size);
spinner.setError_text_size(label_text_size);
spinner.setThickness(thickness);
spinner.setHighlight_color(Color.parseColor("#FFFF00"));
spinner.setErrorMargin(0, thickness);
spinner.setDropDownHintView(getHintView());
//set your hint as ForegroundColorSpanSpannableStringspan = newSpannableString("Spannable String Label *");
span.setSpan(newForegroundColorSpan(Color.RED), span.length() - 1, span.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
spinner.setHint(span);
fetchData();
adapter = newCommonMaterialSpinnerAdapter(this, data);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(newAdapterView.OnItemSelectedListener() {
@OverridepublicvoidonItemSelected(AdapterView<?> parent, Viewview, intposition, longid) {
//Dismiss spinner when you click drop down hint view header.if (position == 0) {
spinner.dismiss();
return;
}
switch (current_node) {
case0:
//Fetch second class data and don't dismiss.fetch2ndClassData();
break;
case1:
//When you current in second class just dismiss your dialog.spinner.dismiss();
return;
}
current_node++;
//Set drop down hint view with back button.spinner.setDropDownHintView(getHintView());
}
@OverridepublicvoidonNothingSelected(AdapterView<?> parent) {
}
});
initDivider(thickness);
initButton();
}
@OverridepublicvoidonClick(Viewv) {
switch (v.getId()) {
caseR.id.submit:
//If your set null to error status will cancel.spinner.setError(TextUtils.isEmpty(spinner.getError()) ? "begin error end" :
"begin error error error error error error error error error error error end");
break;
caseR.id.back:
//Back to first level class.current_node--;
fetchData();
//Reset drop down hint view.spinner.setDropDownHintView(getHintView());
break;
}
}