This is a java code for an image
package com.example.ananduamenon.kindel3;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
public class ToReader extends Activity {
ImageView imageView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.book_covers );
imageView = (ImageView) findViewById( R.id.book_cover51 );
imageView.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent( ToReader.this, com.example.ananduamenon.kindel3.Reader.class );
startActivity( intent );
}
} );
}
}
The XML code for this activity is
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/book_cover51"
android:layout_width="100dp"
android:layout_height="160dp"
android:layout_margin="5dp"
android:contentDescription="@string/todo"
android:scaleType="fitXY"
android:src="@drawable/book_cover"
tools:ignore="RtlHardcoded,RtlSymmetry"
tools:context=".ToReader"/>
This code is working when ToReader code is run as MAIN
But it's not working when I include this XML code is included in the main activity.
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
android:id="@+id/horizontal_scrolls"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<include layout="@layout/book_covers"/>
<include layout="@layout/book_covers"/>
<include layout="@layout/book_covers"/>
<include layout="@layout/book_covers"/>
<include layout="@layout/book_covers"/>
<include layout="@layout/book_covers"/>
<include layout="@layout/book_covers"/>
<include layout="@layout/book_covers"/>
<include layout="@layout/book_covers"/>
</LinearLayout>
</HorizontalScrollView>
Click option is not working now. Is there any requirement when adding XML code while adding with option. The java code is not running in the background at all.