0

Widget で独自の拡張 ProgressBar クラスを使用したいと思います。非常にシンプルな MyProgressBar を作成しました。これを標準のアクティビティ レイアウトに配置すると、機能します。もちろん、デザイナの MyProgressBar プロパティで Style 属性も "?android:attr/progressBarStyleHorizo​​ntal" に設定します。

しかし、同じことをしてウィジェット レイアウトに配置すると、Eclipse のレイアウト デザイナーに表示されますが、ウィジェットはトラゲットでは機能しません。ウィジェットのレイアウトの代わりに「ウィジェットの読み込みに問題があります」というメッセージのみが表示されます....ターゲットデバイスで....

MyProgressBar のソース コードは次のとおりです。

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

ウィジェットはカスタム ビューをサポートしていません。プログレスバーの背景を変更するだけなら、システムのプログレスバーを使用して、レイアウト xml のドローアブルを変更できます。

于 2011-07-04T09:42:22.183 に答える
0

アプリ ウィジェットは次のレイアウト クラスをサポートできます: 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 に答える