2012年11月27日 星期二

[Android]在WidgetConfigure設定完成後更新Widget

假設Widget的Class名稱叫 MyWidget,且 Widget Configure的Class名稱叫WidgetConfig
我們必須在設置好所有設定值時,關閉這個WidgetConfigure的Activity,

所以設定WidConf裡有一個BtnComfirm的按鈕,這個按鈕對應一個btnComfimeOnClick的function。

MyWidget大概長這樣


public class MommyWidget extends AppWidgetProvider {

        @Override
 public void onUpdate(Context context, AppWidgetManager appWidgetManager,
   int[] appWidgetIds) {...}
....
....

...}




WidgetConfigure大概長這樣


public class WidgetConfig extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
...
...}
public void btnComfimeOnClick(View v) {
...
...
}
...

...}





只要在btnComfimeOnClick裡面增加以下程式碼即可在設置完成後更新widget
new MommyWidget().onUpdate(this, awm, widgetIds);

1 則留言:

匿名 提到...

Sometimes you're be} offered holds, which in concept increases your chances. If you're be} offered hold 3 times in a row, almost all video games will spin in the win next when you press the hold buttons a 3rd time. Except that stated win is usually lower than value of|the price of} the four plays it took to get it. Do you attempt to hold two pink sevens and then get killed at the first mystery square? 원 엑스 벳 It will likely solely provide holds twice, and you missed out on two possible minor wins.