Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MWhyte
Last active September 30, 2015 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MWhyte/3e9544e541d7d03a8438 to your computer and use it in GitHub Desktop.
Save MWhyte/3e9544e541d7d03a8438 to your computer and use it in GitHub Desktop.
Using lambda's with android. With help from gradle-retrolambda
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
}
}
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
repositories {
jcenter()
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.newboston.app"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
loginBtn = (Button) findViewById(R.id.login_btn);
loginBtn.setOnClickListener((View) -> login());
Log.i(TAG, "onCreate finished");
}
private void login() {
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment