title: getWindow() from context Android
body: <p>I don't know how to do <em>.setParentLayout(<strong>getWindow()</strong>.getDecorView())</em>
  I'm using a library in order to do Tutorial bubbles, and when a user makes a long click on a gridView's item the bubble appears. The problem is that I don't know how to put context.getWindow() or something like that, I don't know what is supossed to be before getWindow().</p>
  
  <p><strong>GridView_Adapter.class</strong></p>
  
  <pre><code>package es.fingerlabs.gamecohol;
  
  import android.app.Activity;
  import android.content.ContentValues;
  import android.content.Context;
  import android.content.Intent;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.Button;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  
  import com.lovoo.tutorialbubbles.TutorialScreen;
  import com.michael.easydialog.EasyDialog;
  
  import java.util.ArrayList;
  
  public class AdaptadorSobres extends BaseAdapter {
  
  private Context context;
  private ArrayList&lt;Sobre&gt; misSobres = new ArrayList&lt;Sobre&gt;();
  private TutorialScreen botonTutorial;
  private  View gridView;
  public AdaptadorSobres(ArrayList&lt;Sobre&gt; list, Context context) {
      this.misSobres = list;
      this.context = context;
  }
  
  public View getView(final int position, final View convertView, ViewGroup parent) {
  
      gridView = convertView;
      if (gridView == null) {
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          gridView = inflater.inflate(R.layout.item_sobre, null);
      }
  
      TextView TextoNombreSobre = (TextView)gridView.findViewById(R.id.tvNombreSobre);
      TextoNombreSobre.setText(misSobres.get(position).getNombre());
  
      SobresSQLiteHelper sobresdbh = new SobresSQLiteHelper(context, "DBSobres", null, 1);
      SQLiteDatabase db = sobresdbh.getReadableDatabase();
      String[] args = new String[] {Integer.toString(misSobres.get(position).getId())};
      Cursor c = db.rawQuery(" SELECT seleccionado FROM Sobres WHERE id_sobre=? ", args);
      c.moveToFirst();
      final LinearLayout lyItemSobre = (LinearLayout) gridView.findViewById(R.id.lyItemSobre);
      if(c.getInt(0)==0){
          lyItemSobre.setBackgroundResource(R.drawable.rounded_corners_white);
      }else{
          lyItemSobre.setBackgroundResource(R.drawable.rounded_corners_yellow);
      }
  
      gridView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              SobresSQLiteHelper sobresdbh = new SobresSQLiteHelper(context, "DBSobres", null, 1);
              SQLiteDatabase db = sobresdbh.getWritableDatabase();
              String[] args = new String[] {Integer.toString(misSobres.get(position).getId())};
              Cursor c = db.rawQuery(" SELECT comprado FROM Sobres WHERE id_sobre=? ", args);
              c.moveToFirst();
              if(c.getInt(0)==0){
                  Intent intent = new Intent(context, ComprarSobre.class);
                  intent.putExtra("Id", (misSobres.get(position).getId()));
                  intent.putExtra("Nombre", (misSobres.get(position)).getNombre());
                  intent.putExtra("Descripcion", (misSobres.get(position)).getDescripcion());
                  context.startActivity(intent);
              }else{
                  c = db.rawQuery(" SELECT seleccionado FROM Sobres WHERE id_sobre=? ", args);
                  c.moveToFirst();
                  if(c.getInt(0)==0){
                      lyItemSobre.setBackgroundResource(R.drawable.rounded_corners_yellow);
                      ContentValues valores = new ContentValues();
                      valores.put("seleccionado", 1);
                      db.update("Sobres", valores, "id_sobre=" + misSobres.get(position).getId(), null);
                  }else{
                      lyItemSobre.setBackgroundResource(R.drawable.rounded_corners_white);
                      ContentValues valores = new ContentValues();
                      valores.put("seleccionado", 0);
                      db.update("Sobres", valores, "id_sobre=" + misSobres.get(position).getId(), null);
                  }
              }
          }
      });
  
      gridView.setOnLongClickListener(new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
              botonTutorial.showTutorial();
              return false;
          }
      });
  
      gridView.post(new Runnable() {
          @Override
          public void run () {
              LayoutInflater lyInflater = LayoutInflater.from(context);
              botonTutorial = new TutorialScreen.TutorialBuilder(R.layout.tutorial_sobre, gridView)
                      .setParentLayout(getWindow().getDecorView())    // parent layout is necessary for layout approach, use decorView or a root relative layout
                      .setDismissible(true)                           // set if this bubble can be dismissed by clicking somewhere outside of its context
                      .addHighlightView(gridView, false)         // sets the view that should be explained
                      .setOnTutorialLayoutInflatedListener(new TutorialScreen.OnTutorialLayoutInflatedListener() {
                          // you can use this callback to bind the bubble layout and apply logic to it
                          @Override
                          public void onLayoutInflated ( View view ) {
  
                          }
                      })
                      .build();
  
          }
      });
  
      return gridView;
  }
  
  @Override
  public int getCount() {
      return misSobres.size();
  }
  
  @Override
  public Object getItem(int position) {
      return null;
  }
  
  @Override
  public long getItemId(int position) {
      return 0;
  }
  }
  </code></pre>