X Tutup
Skip to content

Commit 05add3c

Browse files
committed
Update on the Android tutorials
1 parent 237a28e commit 05add3c

File tree

365 files changed

+5946
-404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

365 files changed

+5946
-404
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 19
5+
buildToolsVersion "25.0.2"
6+
7+
defaultConfig {
8+
applicationId "com.example.lightswitch"
9+
minSdkVersion 3
10+
targetSdkVersion 3
11+
}
12+
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
17+
}
18+
}
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.lightswitch"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
<uses-sdk android:minSdkVersion="3" />
7+
8+
<application android:icon="@drawable/light_bulb" android:label="@string/app_name">
9+
<activity android:name=".LightSwitchActivity"
10+
android:label="@string/app_name">
11+
<intent-filter>
12+
<action android:name="android.intent.action.MAIN" />
13+
<category android:name="android.intent.category.LAUNCHER" />
14+
</intent-filter>
15+
</activity>
16+
17+
</application>
18+
</manifest>
28 KB
Loading
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.example.lightswitch;
2+
3+
import android.app.Activity;
4+
import android.graphics.drawable.TransitionDrawable;
5+
import android.os.Bundle;
6+
import android.view.View;
7+
import android.view.View.OnClickListener;
8+
import android.widget.ImageView;
9+
import android.widget.ToggleButton;
10+
11+
public class LightSwitchActivity extends Activity {
12+
13+
@Override
14+
public void onCreate(final Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
setContentView(R.layout.main);
17+
18+
final ImageView image = (ImageView) findViewById(R.id.image);
19+
final ToggleButton button = (ToggleButton) findViewById(R.id.button);
20+
button.setOnClickListener(new OnClickListener() {
21+
@Override
22+
public void onClick(final View v) {
23+
TransitionDrawable drawable = (TransitionDrawable) image
24+
.getDrawable();
25+
if (button.isChecked()) {
26+
drawable.startTransition(1000);
27+
} else {
28+
drawable.reverseTransition(1000);
29+
}
30+
}
31+
});
32+
}
33+
}
745 Bytes
Loading
1.16 KB
Loading
1.1 KB
Loading
956 Bytes
Loading
18.2 KB
Loading
35.8 KB
Loading

0 commit comments

Comments
 (0)
X Tutup