Salve a tutti, stavo facendo una piccola app su android studio e mentre provavo a fare una gallery, solo che quando la provo l'app mi va in crash, vi posto il codice, se qualcuno ha voglia e tempo di dargli un occhiata e dirmi dove sbaglio, sarebbe molto gentile! Grazie a tutti!
XML
codice:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:background="#225ED6">
<ImageView
android:id="@+id/selected"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/gallery_relative_layout"
android:layout_marginLeft="30dip"
android:layout_marginRight="30dip"
android:layout_marginTop="30dip" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_above="@+id/gallery_relative_layout"
android:layout_marginTop="300dp"
android:background="#000000" />
<RelativeLayout
android:id="@+id/gallery_relative_layout"
android:layout_width="fill_parent"
android:layout_height="200dip"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:paddingTop="20dp" >
<HorizontalScrollView
android:id="@+id/hor_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/pdma"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="biggerView"
android:src="@drawable/pdma" />
<ImageView
android:id="@+id/pdmb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="biggerView"
android:src="@drawable/pdmb" />
<ImageView
android:id="@+id/pdmc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="biggerView"
android:src="@drawable/pdmc" />
<ImageView
android:id="@+id/pdmd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="biggerView"
android:src="@drawable/pdmd" />
<ImageView
android:id="@+id/pdmf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="biggerView"
android:src="@drawable/pdmf" />
<ImageView
android:id="@+id/pdmg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="biggerView"
android:src="@drawable/pdmg" />
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
</RelativeLayout>
JAVA
codice:
ImageView im;
public void biggerView(View v)
{
im=(ImageView)findViewById(R.id.selected);
switch (v.getId())
{
case R.id.pdma: im.setImageResource(R.drawable.pdma);
break;
case R.id.pdmb: im.setImageResource(R.drawable.pdmb);
break;
case R.id.pdmc: im.setImageResource(R.drawable.pdmc);
break;
case R.id.pdmd: im.setImageResource(R.drawable.pdmd);
break;
case R.id.pdmf: im.setImageResource(R.drawable.pdmf);
break;
case R.id.pdmg: im.setImageResource(R.drawable.pdmg);
break;
}
}