I am having a trouble using Scrollview of linearlayout which contains some imageviews as i want to click on each imageview separately but the onclick method just gives me access to the linearlayout.
this is the layout for the scrollview which contains the linearlayout
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/horizontalScrollView"
android:layout_below="@+id/seekBar"
android:layout_alignParentLeft="true"
android:layout_above="@+id/nextButton"
android:layout_alignParentRight="true" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/eyesScrollView"></LinearLayout>
</HorizontalScrollView>
and i add the imageviews programitically by this code
LinearLayout eyesScrollView = (LinearLayout) findViewById(R.id.eyesScrollView);
for (int k = 0; k < 5; k++) {
ImageView imageView2 = new ImageView(this);
imageView2.setId(k);
imageView2.setPadding(2, 2, 2, 2);
imageView2.setImageBitmap(BitmapFactory.decodeResource(getResources(), eyesArrayList.get(k)));
eyesScrollView.addView(imageView2);
}
and this is the code which access the linearlayout onclick
@Override
public void onClick(View view) {
LinearLayout manyPics = (LinearLayout) view;
manyPics.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view){
Log.v("theID",String.valueOf(view.getId()));
}
});
}
please can anyone helps me with that problem