Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
update
  • Loading branch information
JiaLei123 committed Mar 13, 2017
1 parent 46c30a3 commit 4fb5647
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
.DS_Store
/build
/captures
/.idea

/**/.idea/
9 changes: 2 additions & 7 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</activity>
-->

<activity android:name=".Chapter2.Chapter2PopupWindow">
<activity android:name=".Chapter2.Chapter2DatePickerTimPickerDialog">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.example.jiayu.helloworld.Chapter2;

import android.app.DatePickerDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;

import com.example.jiayu.helloworld.R;

import java.util.Calendar;

public class Chapter2DatePickerTimPickerDialog extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chapter2_date_picker_tim_picker_dialog);

Button datebn = (Button) findViewById(R.id.dateBn);
Button timebn = (Button) findViewById(R.id.timeBn);


datebn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);



new DatePickerDialog(Chapter2DatePickerTimPickerDialog.this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet (DatePicker view,int year, int monthOfYear, int dayOfMonth){
EditText show = (EditText) findViewById(R.id.show);
show.setText("你选择了: " + year + "年 " + monthOfYear + "月 " + dayOfMonth + "日");
}

year,
month,
day
});
}




}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="DateDialog Test"/>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你选择的时间是:"
/>
<EditText
android:id="@+id/show"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>

<Button
android:id="@+id/dateBn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DatePicker"/>

<Button
android:id="@+id/timeBn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TimePicker"/>

</LinearLayout>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Apr 18 23:19:46 CST 2016
#Wed Sep 21 00:34:13 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

0 comments on commit 4fb5647

Please sign in to comment.