updateViews.setTextViewText(R.id.boy,level+" %");
解决方案 »
- popupwindow焦点问题
- 求android播放声音的代码!!!
- 在android上 写一个Email的app,引入了相关的三个包,为什么activation 这个包没有起作用
- 看看我这样能找什么样工作
- 求指点。。。。android开发通用框架
- android tabhost如何设置标签的间距
- android 连接 cmwap 代码 网上搜了好几天了 没有一个可以用的
- 刚入门android,请问android开源到哪一个程度?
- SNE平台与Android平台有什么区别?
- 关于LinerrLayout问题,总是出现"LinearLayout" must be followed by the ' = ' character.
- 运营商名称显示问题?
- 求教~~~android如何实现开机转屏
private static final String CLICK_NAME_ACTION = "com.action.widget.click"; private static RemoteViews rv; @Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++) {
int appWidgetId = appWidgetIds[i];
updateAppWidget(context, appWidgetManager, appWidgetId);
}
} @Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
super.onReceive(context, intent); if (rv == null) {
rv = new RemoteViews(context.getPackageName(), R.layout.main);
}
if (intent.getAction().equals(CLICK_NAME_ACTION)) {
if (uitil.isChange) {
rv.setTextViewText(R.id.TextView01, context.getResources()
.getString(R.string.load)); } else {
rv.setTextViewText(R.id.TextView01, context.getResources()
.getString(R.string.change)); }
Toast.makeText(context, Boolean.toString(uitil.isChange),
Toast.LENGTH_LONG).show();
uitil.isChange = !uitil.isChange; }
AppWidgetManager appWidgetManger = AppWidgetManager
.getInstance(context);
int[] appIds = appWidgetManger.getAppWidgetIds(new ComponentName(
context, widgetProvider.class));
appWidgetManger.updateAppWidget(appIds, rv);
} public static void updateAppWidget(Context context,
AppWidgetManager appWidgeManger, int appWidgetId) {
rv = new RemoteViews(context.getPackageName(), R.layout.main);
Intent intentClick = new Intent(CLICK_NAME_ACTION);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0,
intentClick, 0);
rv.setOnClickPendingIntent(R.id.TextView01, pendingIntent);
appWidgeManger.updateAppWidget(appWidgetId, rv);
}
}