Android Null Pointer Exeption on OnClickListener line
<p>I've a simple test application with a GridView containing an array of buttons, i'm tryng to perform an operation (any operation) touching one of these button.</p>

<p>the main code is this:</p>

<pre><code>package com.example.convert;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.GridView;

public class convert extends Activity {
    //private ListView List;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        String [] elenco = {
                "ciao","questo","è","un esempio","Configurazione"
                };

        ArrayAdapter&lt;String&gt; arrayAdapter = new ArrayAdapter&lt;String&gt;(this,R.layout.oggetto,R.id.testogg,elenco);
        GridView gridview = (GridView) findViewById(R.id.gridview);
        gridview.setAdapter(arrayAdapter);
        Button btn = (Button) (findViewById(R.id.testogg));


        btn.setOnClickListener(new OnClickListener(){
              @Override
              public void onClick(View v) {
                  setContentView(R.layout.oggetto);
              }

            });

    }

}
</code></pre>

<p>the main.xml is the following:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gridview"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:numColumns="auto_fit"
    android:verticalSpacing="10dp"
    android:horizontalSpacing="10dp"
    android:columnWidth="90dp"
    android:stretchMode="columnWidth"
    android:gravity="center"
/&gt;
</code></pre>

<p>and the oggetto.xml contain the following lines:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;

&lt;Button
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:text="@+id/TextView01"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:id="@+id/testogg"&gt;
&lt;/Button&gt;
</code></pre>

<p>But when i try to Run the application it return me a NullPointerExeption on the btn.setOnClickListener(new OnClickListener() line.</p>

<p>May be that happen cause the buttons have the same id? if this is the case, how can i obtain repeated buttons with different ids?</p>

<p>Thanks for your help!</p>
