Este es mi codigo:
Código HTML:
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.GridView; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { private TextView lblMensaje; private GridView gridview; /*private TextView lblEtiqueta; private ListView lstOpciones;*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //lblMensaje = (TextView)findViewById(R.id.textView1); GridView gv1 = (GridView)findViewById(R.id.gridView1); gv1.setAdapter(new ImageAdapter(this)); GridView gv2 = (GridView)findViewById(R.id.gridView2); gv2.setAdapter(new ImageAdapter2(this)); gv1.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Toast.makeText(MainActivity.this, "" + position, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(getApplicationContext(), resultados2.class); //intent.putExtra("id", position); startActivity(intent); } }); gv2.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Toast.makeText(MainActivity.this, "" + position, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(getApplicationContext(), resultados.class); //intent.putExtra("id", position); startActivity(intent); } }); } }
gracias un saludo