title: Start activity from adapter don't work with SwipeListView library
body: <p>I'm using <a href="https://github.com/47deg/android-swipelistview" rel="nofollow">SwipeListView</a> library and I'm getting error when trying to start an activity in my adapter.</p>
  
  <pre><code>public class ProductAdapter extends ArrayAdapter&lt;Product&gt; {
  
  private Context context;
  
  public ProductAdapter(Context context, int textViewResourceId, List&lt;Product&gt; objects) {
      super(context, textViewResourceId, objects);
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
      ViewHolder viewHolder;
  
      final Product product = getItem(position);
  
      if (convertView == null) {
          viewHolder = new ViewHolder();
  
          convertView = LayoutInflater.from(getContext()).inflate(R.layout.cproduct_list_item, null);
  
          viewHolder.nom = (TextView) convertView.findViewById(R.id.name);
          viewHolder.commerce = (TextView) convertView.findViewById(R.id.commerce);
          viewHolder.prix = (TextView) convertView.findViewById(R.id.price);
          viewHolder.bAction1 = (Button) convertView.findViewById(R.id.example_row_b_action_1);
          viewHolder.bAction2 = (Button) convertView.findViewById(R.id.example_row_b_action_2);
          viewHolder.bAction3 = (Button) convertView.findViewById(R.id.example_row_b_action_3);
  
          convertView.setTag(viewHolder);
  
      } 
      else {
          viewHolder = (ViewHolder) convertView.getTag();
      }
  
      viewHolder.nom.setText(product.getName());
      viewHolder.commerce.setText(product.getCommerce());
      viewHolder.prix.setText(String.format("%s F", product.getPrice()));
  
      viewHolder.bAction1.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent = new Intent(context, MainActivity.class);
              context.startActivity(intent);
          }
      });
  
      return convertView;
  }
  
  private class ViewHolder {
      TextView nom;
      TextView commerce;
      TextView prix;
      Button bAction1;
      Button bAction2;
      Button bAction3;
  }
  }
  </code></pre>
  
  <p>When I click on the button I get this error: "The application has stopped unexpectedly". But when I use a Toast, it works fine. I think there is something inconsistent with starting activity.</p>
  
  <p>Logcat:</p>
  
  <blockquote>
    <p>04-16 18:42:29.531: E/AndroidRuntime(29813): FATAL EXCEPTION: main
    04-16 18:42:29.531: E/AndroidRuntime(29813): java.lang.NullPointerException
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at com.tomsyweb.suna.ProductAdapter$2.onClick(ProductAdapter.java:71)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at android.view.View.performClick(View.java:2485)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at android.view.View$PerformClick.run(View.java:9080)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at android.os.Handler.handleCallback(Handler.java:587)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at android.os.Handler.dispatchMessage(Handler.java:92)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at android.os.Looper.loop(Looper.java:130)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at android.app.ActivityThread.main(ActivityThread.java:3687)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at java.lang.reflect.Method.invokeNative(Native Method)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at java.lang.reflect.Method.invoke(Method.java:507)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    04-16 18:42:29.531: E/AndroidRuntime(29813):    at dalvik.system.NativeStart.main(Native Method)</p>
  </blockquote>