Skip to content

Commit 30e8fd1

Browse files
committed
第一次提交
0 parents  commit 30e8fd1

36 files changed

+657
-0
lines changed

Diff for: .gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures

Diff for: .idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/gradle.xml

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/misc.xml

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: app/build.gradle

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin:'kotlin-android'
4+
5+
android {
6+
compileSdkVersion 24
7+
buildToolsVersion "24.0.1"
8+
9+
defaultConfig {
10+
applicationId "com.hellowkotlin"
11+
minSdkVersion 15
12+
targetSdkVersion 24
13+
versionCode 1
14+
versionName "1.0"
15+
}
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20+
}
21+
}
22+
sourceSets{
23+
main.java.srcDirs += 'src/main/kotlin'
24+
}
25+
}
26+
27+
dependencies {
28+
compile fileTree(include: ['*.jar'], dir: 'libs')
29+
testCompile 'junit:junit:4.12'
30+
compile 'com.android.support:appcompat-v7:24.1.1'
31+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
32+
33+
}
34+
repositories {
35+
mavenCentral()
36+
}

Diff for: app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in F:\android\adt-bundle-windows-x86-20140321\sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.hellowkotlin;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

Diff for: app/src/main/AndroidManifest.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.hellowkotlin">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity android:name=".HelloKotlinActivity">
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN" />
14+
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
19+
</application>
20+
21+
</manifest>
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.hellowkotlin
2+
3+
import android.support.v7.app.AppCompatActivity
4+
import android.os.Bundle
5+
import android.widget.Toast
6+
import kotlinx.android.synthetic.main.activity_hello_kotlin.*
7+
8+
class HelloKotlinActivity : AppCompatActivity() {
9+
10+
override fun onCreate(savedInstanceState: Bundle?) {
11+
super.onCreate(savedInstanceState)
12+
setContentView(R.layout.activity_hello_kotlin)
13+
btnlogin.setOnClickListener { check() }
14+
}
15+
16+
fun check(){
17+
if(username!=null && username.length()>0){
18+
if(password!=null && password.length()>0){
19+
Toast.makeText(this,"成功",Toast.LENGTH_LONG).show();
20+
21+
}else{
22+
Toast.makeText(this,"密码不为空",Toast.LENGTH_LONG).show();
23+
return;
24+
}
25+
}else{
26+
Toast.makeText(this,"用户名不为空",Toast.LENGTH_LONG).show();
27+
}
28+
}
29+
}

Diff for: app/src/main/java/com/hellowkotlin/MainActivity.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.hellowkotlin;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
6+
public class MainActivity extends AppCompatActivity{
7+
8+
@Override
9+
protected void onCreate(Bundle savedInstanceState){
10+
super.onCreate(savedInstanceState);
11+
setContentView(R.layout.activity_main);
12+
}
13+
}

Diff for: app/src/main/res/layout/activity_hello_kotlin.xml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:orientation="vertical"
7+
tools:context="com.hellowkotlin.HelloKotlinActivity">
8+
<EditText
9+
android:layout_width="match_parent"
10+
android:id="@+id/username"
11+
android:layout_height="wrap_content" />
12+
<EditText
13+
android:layout_width="match_parent"
14+
android:id="@+id/password"
15+
android:layout_height="wrap_content" />
16+
<Button
17+
android:layout_width="match_parent"
18+
android:id="@+id/btnlogin"
19+
android:layout_height="wrap_content" />
20+
</LinearLayout>

Diff for: app/src/main/res/layout/activity_main.xml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:paddingBottom="@dimen/activity_vertical_margin"
7+
android:paddingLeft="@dimen/activity_horizontal_margin"
8+
android:paddingRight="@dimen/activity_horizontal_margin"
9+
android:paddingTop="@dimen/activity_vertical_margin"
10+
tools:context="com.hellowkotlin.MainActivity">
11+
12+
<TextView
13+
android:layout_width="wrap_content"
14+
android:layout_height="wrap_content"
15+
android:text="Hello World!" />
16+
</RelativeLayout>

Diff for: app/src/main/res/mipmap-hdpi/ic_launcher.png

3.34 KB
Loading

Diff for: app/src/main/res/mipmap-mdpi/ic_launcher.png

2.15 KB
Loading

Diff for: app/src/main/res/mipmap-xhdpi/ic_launcher.png

4.73 KB
Loading

Diff for: app/src/main/res/mipmap-xxhdpi/ic_launcher.png

7.54 KB
Loading

Diff for: app/src/main/res/mipmap-xxxhdpi/ic_launcher.png

10.2 KB
Loading

Diff for: app/src/main/res/values-w820dp/dimens.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources>
2+
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
3+
(such as screen margins) for screens with more than 820dp of available width. This
4+
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
5+
<dimen name="activity_horizontal_margin">64dp</dimen>
6+
</resources>

Diff for: app/src/main/res/values/colors.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#3F51B5</color>
4+
<color name="colorPrimaryDark">#303F9F</color>
5+
<color name="colorAccent">#FF4081</color>
6+
</resources>

Diff for: app/src/main/res/values/dimens.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
<!-- Default screen margins, per the Android Design guidelines. -->
3+
<dimen name="activity_horizontal_margin">16dp</dimen>
4+
<dimen name="activity_vertical_margin">16dp</dimen>
5+
</resources>

Diff for: app/src/main/res/values/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">HellowKotlin</string>
3+
</resources>

Diff for: app/src/main/res/values/styles.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
<item name="colorPrimary">@color/colorPrimary</item>
7+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8+
<item name="colorAccent">@color/colorAccent</item>
9+
</style>
10+
11+
</resources>
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.hellowkotlin;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.*;
6+
7+
/**
8+
* To work on unit tests, switch the Test Artifact in the Build Variants view.
9+
*/
10+
public class ExampleUnitTest {
11+
@Test
12+
public void addition_isCorrect() throws Exception {
13+
assertEquals(4, 2 + 2);
14+
}
15+
}

0 commit comments

Comments
 (0)