0

I would like use my own extended ProgressBar class in Widget. I has created really simple MyProgressBar and if I place this into standart activity layout, it works. Of course I set also Style attribiute to "?android:attr/progressBarStyleHorizontal" in MyProgressBar property in designer.

But if I do same and place it to Widget layout, its visible good in layout designer in eclipse, however, widget does not work in traget. There is only "Problem loaing widget" message showed instead of widget layout .... on target device....

Source code for MyProgressBar is here :

public class MyProgressBar extends ProgressBar {

public MyProgressBar(Context context) {   
    super(context);   
}   

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

public MyProgressBar(Context context, AttributeSet attrs, int defStyle) {   
    super(context, attrs, defStyle);   
}   

@Override  
protected synchronized void onDraw(Canvas canvas) {   
    // First draw the regular progress bar, then custom draw our text   
    super.onDraw(canvas);
}   

}

4

2 回答 2

0

App Widget 可以支持以下布局类:FrameLayout、LinearLayout、RelativeLayout、GridLayout。

以及以下小部件类:AnalogClock、Button、Chronometer、ImageButton、ImageView、ProgressBar、TextView、ViewFlipper、ListView、GridView、StackView、AdapterViewFlipper。

不支持这些类的后代。

复制自:http: //developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout

于 2013-10-06T11:56:47.403 回答
0

小部件不支持自定义视图。如果你只是改变进度条的背景,你可以使用系统的进度条,并改变布局xml中的drawable。

于 2011-07-04T09:42:22.183 回答