-
Notifications
You must be signed in to change notification settings - Fork 144
Open
Description
in my code i image click listener is not working can you bring up with a solution
package com.example.catalogue_application;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import com.denzcoskun.imageslider.ImageSlider;
import com.denzcoskun.imageslider.constants.ScaleTypes;
import com.denzcoskun.imageslider.models.SlideModel;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<SlideModel> imageList = new ArrayList<>();
imageList.add(new SlideModel("https://images.pexels.com/photos/247502/pexels-photo-247502.jpeg?cs=srgb&dl=pexels-pixabay-247502.jpg&fm=jpg", "Lion .", ScaleTypes.CENTER_CROP));
imageList.add(new SlideModel("https://images.unsplash.com/photo-1598755257130-c2aaca1f061c?q=80&w=1000&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8M3x8d2lsZCUyMGFuaW1hbHxlbnwwfHwwfHx8MA%3D%3D", "Zebra.", ScaleTypes.CENTER_CROP));
imageList.add(new SlideModel("https://images.pexels.com/photos/792381/pexels-photo-792381.jpeg?cs=srgb&dl=pexels-george-desipris-792381.jpg&fm=jpg", "Tiger.", ScaleTypes.CENTER_CROP));
imageList.add(new SlideModel("https://static.vecteezy.com/system/resources/previews/022/588/202/original/watercolor-cute-dog-cool-superstar-cartoon-animal-character-isolated-transparent-background-ai-generated-png.png", "Dog.", ScaleTypes.CENTER_CROP));
ImageSlider imageSlider = findViewById(R.id.image_slider);
imageSlider.setImageList(imageList);
imageSlider.stopSliding();
imageSlider.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int position = imageSlider.getCurrentPosition();
// Handle the click event for the image at the specified position
String imageUrl = imageList.get(position).getImageUrl();
Intent intent = new Intent(MainActivity.this, detail_screen.class);
intent.putExtra("imageUrl", imageUrl);
startActivity(intent);
}
});
}
}
ahmedabdallah24
Metadata
Metadata
Assignees
Labels
No labels