2014-01-23 105 views
0

如何在創建小部件或onEnabled時存儲/獲取小部件x,y座標? 我想他們,因爲我想2個imageViews網添加到我的小部件的ImageView 這裏是我的代碼商店小部件位置

public class MyWidgetProvider extends AppWidgetProvider { 
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { 
    final int N = appWidgetIds.length; 

    for (int i=0; i<N; i++) { 
     int appWidgetId = appWidgetIds[i]; 

     Intent intent = new Intent(context, MainActivity.class); 
     PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); 

     RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout); 
     views.setOnClickPendingIntent(R.id.imageView1, pendingIntent); 

     appWidgetManager.updateAppWidget(appWidgetId, views); 
    } 
} 

@Override 
public void onEnabled(Context context) { 
    // TODO Auto-generated method stub 
    super.onEnabled(context); 
    Toast.makeText(context, "Welcome to QNotes Application :)", Toast.LENGTH_LONG).show(); 
} 

@Override 
public void onReceive(Context context, Intent intent) { 
    // TODO Auto-generated method stub 
    super.onReceive(context, intent); 
    Toast.makeText(context,"asd", Toast.LENGTH_LONG).show(); 

} 

回答

0

我改變了主意,並使用透明的活動來代替。