您的位置:首页 > 其它

loadToast浮动框加载提示(自用,记录用)

2015-06-11 15:29 169 查看
loadToast实现加载中,成功,失败浮动框提示。效果图如下:



Step 1

Gradle

dependencies {
compile 'net.steamcrafted:load-toast:1.0.6'
}


Step 2

The API is very simple, create a new toast by providing a context:

LoadToast lt = new LoadToast(context);


Change the displayed text:

lt.setText("Sending Reply...");


Then proceed to show the toast:

lt.show();


When your background thingy is done provide feedback to the user and hide the toast:

// Call this if it was successful

lt.success();


// Or this method if it failed

lt.error();


If you are using translucent actionbar in a full screen activity it will appear over the actionbar, fortunately there is a method to change the y translation:

lt.setTranslationY(100); // y offset in pixels


You can also change the colors of the different toast elements:

lt.setTextColor(Color.RED).setBackgroundColor(Color.GREEN).setProgressColor(Color.BLUE);


These can be chained as you can see.

final String text = "登录中,请稍等...";
final LoadToast lt = new LoadToast(this).setText(text).setTranslationY(100);
//lt.setTextColor(Color.RED).setBackgroundColor(Color.GREEN).setProgressColor(Color.BLUE);
findViewById(R.id.show).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
lt.show();
}
});


代码下载
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: