Wednesday, November 16, 2011

Hide showed Toast Messages

In my App, there is a list, when a user clicks on an button, a toast message is being displayed, 10 items - 10 toast messages, so if the user clicks 10 times, then presses the button... he/she has to wait for some seconds, until he's able to read the menu option text.

I have found the below solution to hide the shows toast message.

public class SampleToastActivity extends Activity {
Toast myToast;
static int i=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b1 = (Button) findViewById(R.id.button2);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
i++;
if(myToast!=null){
myToast.cancel();
myToast.setText("Count"+i);
}else{
myToast = Toast.makeText(SampleToastActivity.this, "Sample"+i, 10);
}
myToast.show();
}
});
}
}

33 comments:

  1. Its great if it will really work. There are too many android applications provided by android app developers so that android mobile phones perform awesome.

    ReplyDelete
  2. Thanks for this information this was really helpful.
    Best Android Apps

    ReplyDelete
  3. your blog is nice,if you upload any screen shots then it's use full to all of us...thanks

    ReplyDelete
  4. Good to know about your blog i have visit and i am very inspired from your ideas It will be interesting to see what we learn about the use of mobile phones in the coming years.

    Big Button Mobile Phones

    ReplyDelete
  5. It's nice information that advice me how to hide showed toast messages in the android smart phone so i say thanks for posting this kind of blog which help me and other user who don't know this kind of facility of android.


    Android App Development

    ReplyDelete
  6. Thanks for share this nice post. Very helpful.

    Android Apps

    ReplyDelete
  7. Recently i am facing this issue, by reading your article now i am able to resolve this bug in my program. Thank for sharing it with us!!!

    apps developers India

    ReplyDelete
  8. Wonderful blog... really helpful for me.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Thanks for sharing the great blog post with us! We provide custom Uber for trucking app development solution and truck dispatch software for logistics and freight businesses to bring simplicity and efficiency to their dispatch operations.
    Hire Angularjs Developers | Truck Dispatch Software | Taxi App Development


    ReplyDelete
  11. It’s hard to come by experienced people about this subject, but you seem like you know what you’re talking about! Thanks

    Digital Marketing Company in Pune

    Software Development Company

    Mobile App Development Compaany

    ReplyDelete
  12. Thank You! For sharing such a great article, It’s been an amazing article. It provides lot’s of information, I really enjoyed to read this, I hope, I will get these kinds of information on a regular basis from your side.
    Apps Development Company in Nigeria
    App Development Company in Zambia

    ReplyDelete
  13. Great blog..Thanks for sharing such a great blog..I like your blog very much…..such a good information..

    Android App Development Company in Noida

    ReplyDelete
  14. Great functionality in this code. I appreciate this post! Thanks for sharing it with us!

    Hire iPhone Developer

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
    smart audit

    smart contract development


    ReplyDelete
  17. Thank You! For sharing such a great article, It’s been an amazing article. It provides lot’s of information. I really enjoyed reading this, I hope I will get these kinds of information on a regular basis from your side.
    iot industrial automation

    hyperledger application development


    ReplyDelete
  18. Thanks for sharing great informative article. I liked it very much. We as a leading mobile app development company and digital marketing agency in Pune always write and appreciate good articles. https://www.appconsultio.com/mobile-app-development-company-pune

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. Playing world777 fantasy cricket games can help you focus on something other than your negative thoughts. Concentrate on putting your cricket knowledge to good use in order to assemble the finest team possible!

    ReplyDelete
  21. This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information. Keep it up. You might also like coin stars near me

    ReplyDelete
  22. Hi, I am John Smith I am Web Developer, It is an amazing blog thanks for the sharing the blog. Frantic infotech provide the Flutter app development such as an information about software development for costumer service. Frantic infotech also provide the native mobile app development. Theve delopment of advanced web applications is Orient Software’s specialty and we will successfully fulfill all your web application development requirements, from small-sized to wider-ranged projects.

    ReplyDelete
  23. motivational article in androide designing and "coding

    ReplyDelete