-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
58 changes: 51 additions & 7 deletions
58
app/src/main/java/com/android/tu/mloadingdialog/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,64 @@ | ||
package com.android.tu.mloadingdialog; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.os.Message; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import com.android.tu.loadingdialog.LoadingDailog; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
public class MainActivity extends AppCompatActivity implements View.OnClickListener{ | ||
|
||
Button btn1,btn2; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
LoadingDailog.Builder builder=new LoadingDailog.Builder(this) | ||
.setShowMessage(false) | ||
.setCancelable(false) | ||
.setCancelOutside(false); | ||
builder.create().show(); | ||
btn1= (Button) findViewById(R.id.style1_btn); | ||
btn2= (Button) findViewById(R.id.style2_btn); | ||
btn1.setOnClickListener(this); | ||
btn2.setOnClickListener(this); | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
switch (view.getId()){ | ||
case R.id.style1_btn: | ||
LoadingDailog.Builder builder1=new LoadingDailog.Builder(MainActivity.this) | ||
.setMessage("加载中...") | ||
.setCancelable(false); | ||
final LoadingDailog dialog1=builder1.create(); | ||
dialog1.show(); | ||
handler.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
dialog1.dismiss(); | ||
} | ||
},2000); | ||
break; | ||
case R.id.style2_btn: | ||
LoadingDailog.Builder builder2=new LoadingDailog.Builder(MainActivity.this) | ||
.setShowMessage(false) | ||
.setCancelable(false); | ||
final LoadingDailog dialog2=builder2.create(); | ||
dialog2.show(); | ||
handler.postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
dialog2.dismiss(); | ||
} | ||
},2000); | ||
break; | ||
} | ||
} | ||
|
||
private Handler handler=new Handler(){ | ||
@Override | ||
public void handleMessage(Message msg) { | ||
super.handleMessage(msg); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:orientation="vertical" | ||
tools:context="com.android.tu.mloadingdialog.MainActivity"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
<Button | ||
android:id="@+id/style1_btn" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Hello World!" /> | ||
</RelativeLayout> | ||
android:background="@android:color/holo_blue_bright" | ||
android:text="style1"/> | ||
|
||
<Button | ||
android:id="@+id/style2_btn" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="@android:color/holo_green_light" | ||
android:text="style2"/> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters