2011-06-29 13 views
0

の場合、アンドロイドウィジェットは表示されません。ウィジェットがあります。クリックすると、透明なバックグラウンドで新しいアクティビティが開始されます。そのウィジェットを非表示にして、ホーム画面にアクティビティが表示されるようにしますウィジェットの上にアクティビティウィンドウが、私は、あなたが以下を使用してリモートビューを作成した場合、次のコードサンプル起動アクティビティが

で試してみてください、私はAPIレベル7を使用していないメソッドの原因をintent.getSourceBounds使用するか、

答えて

0

を用いて全ウィジェットの他の可視性Iは

 public class homeWidget extends AppWidgetProvider { 
public static String ACTION_WIDGET_RECEIVER = "ActionReceiverWidget"; 
@Override 
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) 
    { 
     RemoteViews remoteViews; 
     ComponentName watchWidget; 

     Intent active = new Intent(context, homeWidget.class); 
     active.setAction(ACTION_WIDGET_RECEIVER); 
     PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0); 


     remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); 
     watchWidget = new ComponentName(context, homeWidget.class); 

     remoteViews.setOnClickPendingIntent(R.id.buttonWidget1, actionPendingIntent); 



     appWidgetManager.updateAppWidget(watchWidget, remoteViews); 
    } 
@Override 
public void onEnabled(Context context){ 
    AppWidgetManager mgr = AppWidgetManager.getInstance(context); 
    RemoteViews remoteViews; 
     ComponentName watchWidget; 

     Intent active = new Intent(context, homeWidget.class); 
     active.setAction(ACTION_WIDGET_RECEIVER); 
     PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0); 


     remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); 
     watchWidget = new ComponentName(context, homeWidget.class); 

     remoteViews.setOnClickPendingIntent(R.id.buttonWidget1, actionPendingIntent); 

     mgr.updateAppWidget(watchWidget,remoteViews); 

} 
@Override 
public void onReceive(Context context, Intent intent) { 
    AppWidgetManager mgr = AppWidgetManager.getInstance(context); 
    if (intent.getAction().equals(ACTION_WIDGET_RECEIVER)) { 
     Log.i("proverka", "uleva"); 
     Intent intent1 = new Intent(context,widget_activity.class); 
     PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent1, 0); 
     RemoteViews remoteViews; 
     remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget); 

     ComponentName watchWidget; 
     watchWidget = new ComponentName(context, homeWidget.class); 

     remoteViews.setViewVisibility(R.id.LinearLayout01, View.GONE); 
     try { 
      pendingIntent.send(); 
     } catch (CanceledException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 



     mgr.updateAppWidget(watchWidget,remoteViews); 
     } 
     super.onReceive(context, intent); 
} 

} 
0

上記カントコード

RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget); 

次のコード

views.setViewVisibility(R.id.widget_counter, View.INVISIBLE); 
+0

その行iはonEnabledしている原因とにonUpdate方法を置くために、私は(remoteViews.setOnClickPendingIntentでactivituを呼んでいる解決策を見つけましたR.id.buttonWidget1、pendingIntent); – user742362

+0

もし私がウィジェットを追加するとこれらのメソッドの中身が見えなくなりますが...私はそれをクリックすると非表示にする必要があります – user742362

関連する問題