Closed Meglali20 closed 4 years ago
Hi @Meglali20, You can create a custom adapter using your own customized layout style. The IconSpinnerAdapter is one of the customized adapters provided in this library.
Hi @Meglali20, You can create a custom adapter using your own customized layout style. The IconSpinnerAdapter is one of the customized adapters provided in this library.
Thank you for your answer. I am using java, I added a custom adapter the problem is with this override fun notifyItemSelected(index: Int) { this.spinnerView.notifyItemSelected(index, this.spinnerItems[index].text) this.onSpinnerItemSelectedListener?.onItemSelected(index, this.spinnerItems[index]) }
@NotNull
@Override
public PowerSpinnerView getSpinnerView() {
return null;
}
it returns a null and must be NonNull where should I assign the PowerSpinnerView it should return?
As you can see the IconSpinnerAdapter
, You can hand over PwerSpinnerView
via the constructor.
Also when implementing your custom adapter, you should define PowerSpinnerView
field in your class and it can be used for applying attributes on your own ViewHolder. The PowerSpinnerView
has many kinds of attributes including text color, typeface, text size, padding or etc from XML layout. And they might be used in your custom adapter.
@skydoves but where to assign the value of powerSpinnerView?
For writing an example of the IconSpinnerAdapter
:
IconSpinnerAdapter adapter = new IconSpinnerAdapter(myPowerSpinnerView);
Add a new constructor to your custom adapter.
Here is an example codes using IconSpinnerItem
written Java.
class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.CustomViewHolder>
implements PowerSpinnerInterface<IconSpinnerItem> {
private PowerSpinnerView powerSpinnerView;
public CustomAdapter(PowerSpinnerView powerSpinnerView) {
this.powerSpinnerView = powerSpinnerView;
}
@NotNull @Override public PowerSpinnerView getSpinnerView() {
return powerSpinnerView;
}
Thank you, I got this part, but when calling notifyItemSelected(i, String.valueOf(i)); it will only set the text for the powerSpinnerView not display the image or the full item
@skydoves
I figured it out from the IconSpinnerAdapter.kt class, thank you for your help!
Hi, Great spinner! I would like to change something, I want to put the text below the image is there a way to that?