Skip to content

Commit

Permalink
修改不显示加载信息的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gittjy committed Jun 19, 2017
1 parent 622eae1 commit eec1413
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

58 changes: 51 additions & 7 deletions app/src/main/java/com/android/tu/mloadingdialog/MainActivity.java
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);
}
};
}
25 changes: 16 additions & 9 deletions app/src/main/res/layout/activity_main.xml
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>
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public static class Builder{

private Context context;
private String message;
private boolean isShowMessage;
private boolean isCancelable;
private boolean isCancelOutside;
private boolean isShowMessage=true;
private boolean isCancelable=false;
private boolean isCancelOutside=false;


public Builder(Context context) {
Expand Down

0 comments on commit eec1413

Please sign in to comment.