0

この例 (AutoResizeTextView)この例 (FontFitTextView)を使用して、ウィジェットのテキストのサイズを変更しようとしました。

BroadcastReceiverウィジェットを更新する があり、これにBroadcastReceiverは次のものがあります。私は以下を構築しRemoteViewます:

AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(mContext);
ComponentName thisWidget = new ComponentName(mContext, Widget.class);
RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.widget);

次に、変数の 1 つを設定します。

//convert to Fahrenheit if Fahrenheit selected
views.setTextViewText(R.id.wTemperature, convertTemperature(parts[4]) + "\u00B0");

それに応じてwidget.xmlを調整しました:

<uk.co.diong.weatherlive_ish.FontFitTextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textColor="#ffffff"
    android:textSize="29sp"
    android:textStyle="bold"
    android:gravity="center"
    android:text="Temp"
    android:id="@+id/wTemperature" />

しかし、私のウィジェットには「ウィジェットの読み込みに問題がある」と表示されるようになったので、数時間後に疑問に思っています。これは RemoteViews で動作しますか? これらのクラスは両方とも TextView を拡張し、RemoteView は拡張しません。

編集:LogCatにはこれがあります:

04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method     android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 11389: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 11395: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.view.ViewGroup.onWindowSystemUiVisibilityChanged, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onWindowSystemUiVisibilityChanged
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 11397: Landroid/view/ViewGroup;.onWindowSystemUiVisibilityChanged (I)V
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0008
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 9075: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
04-22 17:38:13.213  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.view.ViewGroup.onRtlPropertiesChanged, referenced from method android.support.v7.widget.Toolbar.onRtlPropertiesChanged
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 11392: Landroid/view/ViewGroup;.onRtlPropertiesChanged (I)V
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0007
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 387: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish W/dalvikvm﹕ VFY: unable to resolve virtual method 409: Landroid/content/res/TypedArray;.getType (I)I
04-22 17:38:13.223  14405-14405/uk.co.diong.weatherlive_ish D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
4

2 に答える 2

0

以下の答えが正しいかどうかはわかりませんが、試してみてください

この問題は、Android の新しいレイアウト機能を使用するために必要な主な依存関係の com.android.support:appcompat-v7:21.0.3 が原因である可能性があります。v7:20.0.0 に戻してみてください。これで問題が解決するはずです。

ここから見つけた

https://stackoverflow.com/a/27989207/3728591

于 2015-04-24T13:09:30.917 に答える