diff --git a/README.md b/README.md index 22eb0e3..f0956c6 100644 --- a/README.md +++ b/README.md @@ -70,14 +70,18 @@ FancyToast.makeText(this,"Hello World !",FancyToast.LENGTH_LONG,FancyToast.CONFU ``` You can also remove the android icon on top-right corner by passing last parameter false. ``` java -FancyToast.makeText(yourContext, "I'm a Toast", duration, type, boolen value).show(); +FancyToast.makeText(yourContext, "I'm a Toast", duration, type, boolean value).show(); ``` -You can also create your custom Toasts with passing your image: +You can also create your custom Toasts with passing your image with or without android icon(top-right corner): ``` java -FancyToast.makeText(yourContext, "I'm a custom Toast", duration, type, yourimage).show(); +FancyToast.makeText(yourContext, "I'm a custom Toast", duration, type, yourimage, boolean value).show(); ``` +To display the custom Toast with no android icon: +``` java +FancyToast.makeText(this, "This is Custom Toast with no android icon", FancyToast.LENGTH_LONG, FancyToast.CONFUSING, R.drawable.ic_android_black_24dp, false); +``` ## Screenshots **Please click the image below to enlarge.** diff --git a/app/src/main/java/com/shashank/sony/fancytoastlibrary/MainActivity.java b/app/src/main/java/com/shashank/sony/fancytoastlibrary/MainActivity.java index 49389e7..91eb35b 100644 --- a/app/src/main/java/com/shashank/sony/fancytoastlibrary/MainActivity.java +++ b/app/src/main/java/com/shashank/sony/fancytoastlibrary/MainActivity.java @@ -9,20 +9,21 @@ import com.shashank.sony.fancytoastlib.FancyToast; public class MainActivity extends AppCompatActivity implements View.OnClickListener { - Button b1,b2,b3,b4,b5,b6,b7,b8,b9; + Button b1, b2, b3, b4, b5, b6, b7, b8, b9; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - b1=(Button) findViewById(R.id.button); - b2=(Button) findViewById(R.id.button2); - b3=(Button) findViewById(R.id.button3); - b4=(Button) findViewById(R.id.button4); - b5=(Button) findViewById(R.id.button5); - b6=(Button) findViewById(R.id.button6); - b7=(Button) findViewById(R.id.button7); - b8=(Button) findViewById(R.id.button8); - b9=(Button) findViewById(R.id.button9); + b1 = (Button) findViewById(R.id.button); + b2 = (Button) findViewById(R.id.button2); + b3 = (Button) findViewById(R.id.button3); + b4 = (Button) findViewById(R.id.button4); + b5 = (Button) findViewById(R.id.button5); + b6 = (Button) findViewById(R.id.button6); + b7 = (Button) findViewById(R.id.button7); + b8 = (Button) findViewById(R.id.button8); + b9 = (Button) findViewById(R.id.button9); b1.setOnClickListener(this); b2.setOnClickListener(this); b3.setOnClickListener(this); @@ -35,24 +36,24 @@ protected void onCreate(Bundle savedInstanceState) { } @Override - public void onClick(View v) - { if(v.getId()==R.id.button) - FancyToast.makeText(this,"This is Default Toast",FancyToast.LENGTH_LONG,FancyToast.DEFAULT,true).show(); - else if(v.getId()==R.id.button2) - FancyToast.makeText(this,"Success Toast !",FancyToast.LENGTH_LONG,FancyToast.SUCCESS,true).show(); - else if(v.getId()==R.id.button3) - FancyToast.makeText(this,"This is an Error Toast",FancyToast.LENGTH_LONG,FancyToast.ERROR,true).show(); - else if(v.getId()==R.id.button4) - FancyToast.makeText(this,"Beware of dog",FancyToast.LENGTH_LONG,FancyToast.WARNING,true).show(); - else if(v.getId()==R.id.button5) - FancyToast.makeText(this,"Here is some Info for you",FancyToast.LENGTH_LONG,FancyToast.INFO,true).show(); - else if(v.getId()==R.id.button6) - FancyToast.makeText(this,"This is Confusing Toast",FancyToast.LENGTH_LONG,FancyToast.CONFUSING,false).show(); - else if(v.getId()==R.id.button7) - FancyToast.makeText(this,"This is Custom Toast",FancyToast.LENGTH_LONG,FancyToast.CONFUSING,R.drawable.ic_android_black_24dp).show(); - else if(v.getId()==R.id.button8) - FancyToast.makeText(this,"This is Custom Toast with no android icon",FancyToast.LENGTH_LONG,FancyToast.CONFUSING,R.drawable.ic_android_black_24dp, false).show(); - else if(v.getId()==R.id.button9) - FancyToast.makeText(this,"This is a Success Toast",FancyToast.LENGTH_LONG,FancyToast.SUCCESS,false).show(); + public void onClick(View v) { + if (v.getId() == R.id.button) + FancyToast.makeText(this, "This is Default Toast", FancyToast.LENGTH_LONG, FancyToast.DEFAULT, true).show(); + else if (v.getId() == R.id.button2) + FancyToast.makeText(this, "Success Toast !", FancyToast.LENGTH_LONG, FancyToast.SUCCESS, true).show(); + else if (v.getId() == R.id.button3) + FancyToast.makeText(this, "This is an Error Toast", FancyToast.LENGTH_LONG, FancyToast.ERROR, true).show(); + else if (v.getId() == R.id.button4) + FancyToast.makeText(this, "Beware of dog", FancyToast.LENGTH_LONG, FancyToast.WARNING, true).show(); + else if (v.getId() == R.id.button5) + FancyToast.makeText(this, "Here is some Info for you", FancyToast.LENGTH_LONG, FancyToast.INFO, true).show(); + else if (v.getId() == R.id.button6) + FancyToast.makeText(this, "This is Confusing Toast", FancyToast.LENGTH_LONG, FancyToast.CONFUSING, false).show(); + else if (v.getId() == R.id.button7) + FancyToast.makeText(this, "This is Custom Toast", FancyToast.LENGTH_LONG, FancyToast.CONFUSING, R.drawable.ic_android_black_24dp, true).show(); + else if (v.getId() == R.id.button8) + FancyToast.makeText(this, "This is Custom Toast with no android icon", FancyToast.LENGTH_LONG, FancyToast.CONFUSING, R.drawable.ic_android_black_24dp, false).show(); + else if (v.getId() == R.id.button9) + FancyToast.makeText(this, "This is a Success Toast", FancyToast.LENGTH_LONG, FancyToast.SUCCESS, false).show(); } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 31ff281..bcc90ef 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -11,9 +11,9 @@ android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Default" + android:layout_alignParentStart="true" android:layout_alignParentTop="true" - android:layout_alignParentStart="true" /> + android:text="Default" />