Android - Custom Widget doesnt update

Posted by david on Stack Overflow See other posts from Stack Overflow or by david
Published on 2010-05-11T04:51:24Z Indexed on 2010/05/11 4:54 UTC
Read the original article Hit count: 263

Filed under:
|
|

Hi,

I'm trying to make a widget to my app, but it doesnt update. I just need to change the textview text and open an activity when a press a button, but none of them works...

  • the code

public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.newswidget);
    views.setTextViewText(R.id.tvNews, "prueba1");
    views.setString(R.id.tvNews, "setText", "prueba3");

    Intent intent = new Intent(context, DoctorChatAndroid.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
    views.setOnClickPendingIntent(R.id.ibNext, pendingIntent);

    for (int i = 0; i < appWidgetIds.length; i++) {
        appWidgetManager.updateAppWidget(i, views);
    }
  • the layout

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content">

    <ImageButton
        android:id="@+id/ibNext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_media_ff"
        android:layout_alignParentRight="true"/>
    <ImageButton
        android:id="@+id/ibLast"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_media_rew"
        android:layout_toLeftOf="@id/ibNext"/>
    <TextView
        android:id="@+id/tvNews"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/nwNoNewAnswer"
        android:layout_toLeftOf="@id/ibLast"/>

</RelativeLayout>
  • the other xml

thx a lot!!!

© Stack Overflow or respective owner

Related posts about android

Related posts about widget