android - How to pass AttributeSet as a parameter -
i'm trying implement updated solution pedram this answer, don't know create new instance of circleprogressbar
. requires attributeset passed parameter, how it?
circleprogressbar circleprogressbar = new circleprogressbar(mainactivity.this, ?);
the attributeset
constructor used when view inflated through layout defined in xml. if you're constructing 1 in code, should use single argument constructor (e.g. new circleprogressbar(mainactivity.this)
). if single-argument constructor not defined, need add it. you'll need add getters/setters properties if want able construct entirely within java code.
alternately, define layout xml (example name view_progress_circle.xml) single item:
<com.your.packagename.circleprogressbar android:layout_width="100dp" android:layout_height="100dp" // etc. add other attributes here />
then in code, create with:
circleprogressbar bar = (circleprogressbar) layoutinflater.from(mainactivity.this) .inflate(r.layout.view_progress_circle, parent, false):
where parent
viewgroup
you're going attach view to.
Comments
Post a Comment