小部件文本不更新

时间:2018-01-05 16:46:30

标签: java android widget

代码:

private static void setText(Context context, AppWidgetManager appWidgetManager, int appWidgetId, RemoteViews views, String txt){
    // Construct the RemoteViews object
    views.setTextViewText(R.id.appwidget_text, txt);
    String h = String.valueOf(Calendar.getInstance().get(Calendar.HOUR_OF_DAY));
    if(h.length()==1) h = "0"+h;
    String m = String.valueOf(Calendar.getInstance().get(Calendar.MINUTE));
    if(m.length()==1) m = "0"+m;
    views.setTextViewText(R.id.textView, "Legion19 - " + h + ":" + m);
    String players = "";
    if(Servicio.instancia!=null && Servicio.instancia.players!=null) {
        Log.d("Legion19", Servicio.instancia.players.toString());
        for (int x = 0; x != Servicio.instancia.players.size(); x++)
            players += Servicio.instancia.players.get(x) + "\n";
    }
    views.setTextViewText(R.id.listaJug, players);

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}

appwidget_text和textView得到更新,但是listaJug没有。 我不知道是什么问题,记录:

  

01-05 17:45:48.685 2496-2496 / com.google.android.googlequicksearchbox:搜索I / MicroDetector:保持麦克风打开:false   01-05 17:45:48.685 2496-2496 / com.google.android.googlequicksearchbox:搜索I / MicroDetectionWorker:#onError(false)   01-05 17:45:48.685 2496-10360 / com.google.android.googlequicksearchbox:搜索I / DeviceStateChecker:DeviceStateChecker已取消   01-05 17:45:49.960 1452-1480 /? W / audio_hw_generic:没有向HAL提供足够的数据,预期位置9035474,只写了9035280   01-05 17:45:49.961 10131-10131 / xyz.legion19.legion19 D / Legion19:[SrAnGelXr3,Noemar19,ROXOLIN,rogermiranda1000]

online_players.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#09C"
android:padding="@dimen/widget_margin">

<TextView
    android:id="@+id/appwidget_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:background="#09C"
    android:text="Cargando..."
    android:textColor="#ffffff"
    android:textSize="22sp"
    android:textStyle="bold|italic" />

<TextView
    android:id="@+id/listaJug"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/appwidget_text"
    android:layout_centerHorizontal="true" />

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/appwidget_text"
    android:layout_centerHorizontal="true" />

0 个答案:

没有答案