-1

I have created android app using GridView with ViewPager for images like gallery or small book which have 14 images

in my main activity showing error :- error: lambda expressions are not supported in -source 1.7 (use -source 8 or higher to enable lambda expressions)

check screenshot:- http://prntscr.com/jw6pdd

Please review my code and guide me how can I solve this problem. Here is my code:-

private void setGridViewItemClickListener(){
        gridView.setOnItemClickListener((parent, view, position, id) -> {
            Bundle bundle = new Bundle();
            bundle.putInt("position", position);
            bundle.putStringArrayList("imageURLs", listImageURLs);
            Intent intent = new Intent(this, ImageActivity.class);
            intent.putExtras(bundle);
            startActivity(intent);
        });
    }
Ayan
  • 13
  • 5

1 Answers1

0

Lamda expressions are supported from Java 8. Add following in your build.gradle

android {
  ...

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}
Sagar
  • 23,903
  • 4
  • 62
  • 62