Android: Force close onclick button listview
<p>When i click the button i have an exeption and force close</p>

<p>Adapter code:</p>

<pre><code>public class myAdapter extends BaseAdapter implements OnClickListener {

private ArrayList&lt;produit&gt; produits;
private LayoutInflater myInflater;

public myAdapter(Context context, ArrayList&lt;produit&gt; _produits) {
    this.myInflater = LayoutInflater.from(context);
    this.produits = _produits;

}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return this.produits.size();
}

@Override
public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return this.produits.get(arg0);
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (null == convertView) {
        convertView = myInflater.inflate(R.layout.listitem, null);
    }

    Button btn = (Button) convertView.findViewById(R.id.button1);
    btn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(v.getContext(), Local.class);
            v.getContext().startActivity(i);

        }
    });
    // set the text
    TextView tv = (TextView) convertView.findViewById(R.id.textView1);
    tv.setText(produits.get(position).nom);
    return convertView;

}

@Override
public void onClick(View v) {
    Log.v("bonjour", "Row button clicked");
}

}
</code></pre>

<p>main code :</p>

<pre><code>public class Main extends Activity {


 private ArrayList&lt;produit&gt;produits=new ArrayList&lt;produit&gt;();


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    produits.add(new produit("marlboro"));
    produits.add(new produit("sabrine"));

    ListView list = (ListView)findViewById(R.id.listView1);
    myAdapter adpt = new myAdapter (this,produits);

    list.setAdapter(adpt);

}
}
</code></pre>

<p>Logcat:</p>

<p>03-22 09:52:51.188: E/AndroidRuntime(480): ERROR: thread attach failed
03-22 09:52:52.259: E/AndroidRuntime(488): ERROR: thread attach failed
03-22 09:52:54.388: W/dalvikvm(495): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
03-22 09:52:54.388: E/AndroidRuntime(495): Uncaught handler: thread main exiting due to uncaught exception
03-22 09:52:54.408: E/AndroidRuntime(495): android.content.ActivityNotFoundException: Unable to find explicit activity class {wassim.list/wassim.list.Local}; have you declared this activity in your AndroidManifest.xml?
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.app.Activity.startActivityForResult(Activity.java:2749)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.app.Activity.startActivity(Activity.java:2855)
03-22 09:52:54.408: E/AndroidRuntime(495):  at wassim.list.myAdapter$1.onClick(myAdapter.java:63)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.View.performClick(View.java:2364)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.View.onTouchEvent(View.java:4179)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.widget.TextView.onTouchEvent(TextView.java:6541)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.View.dispatchTouchEvent(View.java:3709)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
03-22 09:52:54.408: E/AndroidRuntime(495):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
03-22 09:52:54.408: E/AndroidRuntime(495):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
03-22 09:52:54.408: E/AndroidRuntime(495):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.os.Looper.loop(Looper.java:123)
03-22 09:52:54.408: E/AndroidRuntime(495):  at android.app.ActivityThread.main(ActivityThread.java:4363)
03-22 09:52:54.408: E/AndroidRuntime(495):  at java.lang.reflect.Method.invokeNative(Native Method)
03-22 09:52:54.408: E/AndroidRuntime(495):  at java.lang.reflect.Method.invoke(Method.java:521)
03-22 09:52:54.408: E/AndroidRuntime(495):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
03-22 09:52:54.408: E/AndroidRuntime(495):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
03-22 09:52:54.408: E/AndroidRuntime(495):  at dalvik.system.NativeStart.main(Native Method)
03-22 09:57:54.618: W/InputManagerService(51): Got RemoteException sending setActive(false) notification to pid 495 uid 10030</p>

<p>How can I make this work?</p>
