<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > 介紹桌面widgets和AppWidget框架(譯)

介紹桌面widgets和AppWidget框架(譯)

作者: 時(shí)間:2016-10-08 來(lái)源:網(wǎng)絡(luò ) 收藏

updateViews.setTextViewText(R.id.word_type, matcher.group(2));

updateViews.setTextViewText(R.id.definition, matcher.group(3).trim());

// When user clicks on widget, launch to Wiktionary definition page

String definePage = res.getString(R.string.template_define_url,

Uri.encode(wordTitle));

Intent defineIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(definePage));

PendingIntent pendingIntent = PendingIntent.getActivity(context,

0 /* no requestCode */, defineIntent, 0 /* no flags */);

updateViews.setOnClickPendingIntent(R.id.widget, pendingIntent);

} else {

// Didn’t find word of day, so show error message

updateViews = new RemoteViews(context.getPackageName(),

R.layout.widget_message);

CharSequence errorMessage = context.getText(R.string.widget_error);

updateViews.setTextViewText(R.id.message, errorMessage);

}

return updateViews;

}

@Override public IBinder onBind(Intent intent) {

// We don’t need to bind to this service

return null;

}

}

}

到這里,你已經(jīng)完成了一個(gè)簡(jiǎn)單的widget,它將顯示W(wǎng)iktionary “Word of the day.”。當一個(gè)更新被請求時(shí),我們讀在線(xiàn)API將最新的數據push到widget上。AppWidget framework會(huì )按我們的需要自動(dòng)更新,例如當一個(gè)新的widget添加時(shí),或者新的一天加載新的Word of the day.”。

最后,這里給出一些建議。Widgets推薦被設計成longer-term的內容,不應該經(jīng)常的被更新。超過(guò)每小時(shí)的頻繁更新會(huì )快速消耗掉電量和帶寬。建議盡可能的不要頻繁更新,或者讓你的用戶(hù)自定義一個(gè)更新周期。例如有些人可能想stock ticker每15分鐘更新一次,或者可能是一天更新四次。我將在我的另一篇文章giving at Google I/O討論節省電量的一些額外的策略。

最后要提的一件比較酷的事是AppWidget framework對方向并不關(guān)心(is abstracted in both directions).這意味著(zhù)你可以在兩個(gè)home screen都可以包含widgets。你的widgets可以被添加到任何一個(gè)支持AppWidgetframework的home screen上。

我們已經(jīng)開(kāi)發(fā)了幾個(gè)自己的widgets,例如Calendar和Music widgets,但是我們更希望看到你開(kāi)發(fā)的widgets.


上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞:

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>