GAMA
GAMA

Reputation: 5996

No such method exception in RangeSeekBar

I've referred RangeSeekBar to implement Seekbar with two thumbs.

I'm getting following error in log:

Caused by: java.lang.NoSuchMethodException: RangeSeekBar(Context,AttributeSet)

and if I try to add following method in RangeSeekBar.java, I'm getting error as : The blank final field numberType may not have been initialized

public RangeSeekBar(Context context, AttributeSet attrs) {
 super(context, attrs);
 }

I'm banging my head from few hours, but haven't find any fruitful solution.

Any help appreciated.
Any other way to implement SeekBar With Two thumb is also welcome.

Upvotes: 0

Views: 312

Answers (1)

Kayhan Asghari
Kayhan Asghari

Reputation: 2844

Any custom view in android should have a constructor like you wrote. So, keep it. The problem is, you have a final field in your class, that should be initialized in constructor. So, remove final modifier from that variable, or set it to some value in constructor.

About RangeSeekBar:
this class is using generic types for detecting what type of number you want to use (float, double, or just int values). So, do not put this as a view in xml layout file, and add it in code like this:

someViewGroup.addView(new RangeSeekBar<Integer>(0, 10, context));

which someViewGroup is the view you want to put RangeSeekBar in it. (its parent).

Upvotes: 1

Related Questions