package com.marshalchen.common.demoofui.sampleModules; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import com.marshalchen.common.demoofui.R; import net.steamcrafted.loadtoast.LoadToast; public class LoadToastLibActivity extends Activity { // Example activity @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.load_toast_lib_activity_main); final String text = "Sending reply..."; final LoadToast lt = new LoadToast(this).setText(text).setTranslationY(100).show(); final ViewGroup root = (ViewGroup) findViewById(android.R.id.content); View v = new View(this); v.setBackgroundColor(Color.RED); root.addView(v, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 400)); findViewById(R.id.show).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { lt.show(); } }); findViewById(R.id.error).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { lt.error(); } }); findViewById(R.id.success).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { lt.success(); } }); findViewById(R.id.refresh).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { View v = new View(LoadToastLibActivity.this); v.setBackgroundColor(Color.rgb((int)(Math.random() * 255), (int)(Math.random() * 255), (int)(Math.random() * 255))); root.addView(v, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 400)); } }); } }