जब आप अपना रिमोट व्यू बना रहे हैं तो आपको लेआउट चुनना होगा। मेरे विजेट कोड में:
public static RemoteViews buildUpdate(Context context, String action) {
RemoteViews updateViews;
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, 0);
String typeface = prefs.getString("typeface", "sans");
int layoutId = R.layout.widget_sans;
if ("monospace".equals(typeface)){
layoutId = R.layout.widget_mono;
} else if ("serif".equals(typeface)){
layoutId = R.layout.widget_serif;
}
updateViews = new RemoteViews(context.getPackageName(),
layoutId);
//actually do things here
//then finally, return our remoteView
AppWidgetManager.getInstance(context).updateAppWidget(
new ComponentName(context, FuzzyWidget.class), updateViews);
}
स्रोत
2009-12-07 17:37:27
तो यह layoutID है कि मैं जरूरत है? मैंने देखा कि updateAppWidget विधि इसका उपयोग नहीं करती है। –
क्षमा करें - मुझे एक पंक्ति याद आई; तय है कि। UpdateAppWidget को पास करने के लिए आपको पैकेज नाम और लेआउट आईडी के साथ एक नया रिमोट व्यू बनाना है। –