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
.
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dp"
android:minHeight="72dp"
android:updatePeriodMillis="3000"
android:initialLayout="@layout/newswidget">
</appwidget-provider>
thx a lot!!!