Autore Topic: onItemClick(AdapterView<?>  (Letto 606 volte)

Offline Spagna

  • Utente junior
  • **
  • Post: 81
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy
  • Sistema operativo:
    windows 7
onItemClick(AdapterView<?>
« il: 25 Gennaio 2013, 20:52:52 CET »
0
Buona sera a tutti,
non riesco a visualizare una imagine selezionada da un GRIDVIEW la aplicazione non si interrompe pero il Layout non viisualiza la imagenes

GridView.java:
Codice (Java): [Seleziona]
 girGridView.setAdapter(new ImageAdapter(this));
       
        girGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                        @Override
                        public void onItemClick(AdapterView<?> arg0, View view, int position,long arg3) {
                                Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                intent.putExtra("id", position);
                startActivity(intent);



                        }
                });
MainActivity.java:
Codice (Java): [Seleziona]
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Bitmap;
import android.widget.ImageView;

public class MainActivity extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main);
                 Bitmap foto = null;
             foto = (Bitmap)this.getIntent().getParcelableExtra("id");
                 ImageView iv = (ImageView)findViewById(R.id.imagen);
             iv.setImageBitmap(foto);

        }



}
Activity_mail.xml:
Codice (Java): [Seleziona]
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <ImageView
            android:id="@+id/imagen"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/icon" />

    </LinearLayout>
Log.cat:
Codice (Java): [Seleziona]
01-25 19:27:57.473: E/Zygote(33): setreuid() failed. errno: 2
01-25 19:28:06.983: E/Zygote(33): setreuid() failed. errno: 17
01-25 19:28:08.323: E/BatteryService(61): usbOnlinePath not found
01-25 19:28:08.323: E/BatteryService(61): batteryVoltagePath not found
01-25 19:28:08.323: E/BatteryService(61): batteryTemperaturePath not found
01-25 19:28:08.353: E/SurfaceFlinger(61): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
01-25 19:28:08.463: E/SensorService(61): couldn'
t open device for module sensors (Invalid argument)
01-25 19:28:15.643: E/System(61): Failure starting core service
01-25 19:28:15.643: E/System(61): java.lang.SecurityException
01-25 19:28:15.643: E/System(61):       at android.os.BinderProxy.transact(Native Method)
01-25 19:28:15.643: E/System(61):       at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
01-25 19:28:15.643: E/System(61):       at android.os.ServiceManager.addService(ServiceManager.java:72)
01-25 19:28:15.643: E/System(61):       at com.android.server.ServerThread.run(SystemServer.java:206)
01-25 19:28:15.725: E/EventHub(61): could not get driver version for /dev/input/mouse0, Not a typewriter
01-25 19:28:15.725: E/EventHub(61): could not get driver version for /dev/input/mice, Not a typewriter
01-25 19:28:16.364: E/SoundPool(61): error loading /system/media/audio/ui/Effect_Tick.ogg
01-25 19:28:16.374: E/SoundPool(61): error loading /system/media/audio/ui/KeypressStandard.ogg
01-25 19:28:16.374: E/SoundPool(61): error loading /system/media/audio/ui/KeypressSpacebar.ogg
01-25 19:28:16.374: E/SoundPool(61): error loading /system/media/audio/ui/KeypressDelete.ogg
01-25 19:28:16.374: E/SoundPool(61): error loading /system/media/audio/ui/KeypressReturn.ogg
01-25 19:28:16.433: E/UsbObserver(61): java.lang.NullPointerException
01-25 19:28:16.433: E/UsbObserver(61):  at com.android.server.UsbObserver.init(UsbObserver.java:131)
01-25 19:28:16.433: E/UsbObserver(61):  at com.android.server.UsbObserver.<init>(UsbObserver.java:65)
01-25 19:28:16.433: E/UsbObserver(61):  at com.android.server.ServerThread.run(SystemServer.java:402)
01-25 19:28:17.064: E/ThrottleService(61): Could not open GPS configuration file /etc/gps.conf
01-25 19:28:19.034: E/logwrapper(152): executing /system/bin/tc failed: No such file or directory
01-25 19:28:19.124: E/logwrapper(154): executing /system/bin/tc failed: No such file or directory
01-25 19:28:19.163: E/logwrapper(156): executing /system/bin/tc failed: No such file or directory
01-25 20:47:03.313: E/InputDispatcher(61): channel '40577880 com.gridview.sample/com.gridview.sample.MyGridView (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
01-25 20:47:03.323: E/InputDispatcher(61): channel '40577880 com.gridview.sample/com.gridview.sample.MyGridView (server)' ~ Channel is unrecoverably broken and will be disposed!
Se qualcuno mi da una mano
Grazie
Un saluto