Toast.makeText from resource string

前端 未结 4 1522
南旧
南旧 2020-12-29 17:00

I have a class named MyPrimaryClass, this class has a button witch when pressed, creates an Intent with the class myClassForResult.

I use this to start it:



        
4条回答
  •  失恋的感觉
    2020-12-29 17:26

    @dilipkaklotar Answered correctly but a few changes needs to be done:

    this is how it worked for me

    Toast.makeText(getApplicationContext(),
    getApplicationContext().getResources().getString(R.string.message),
    Toast.LENGTH_SHORT).show();
    

    the getResources has no parenthesis (). and at the end is .show(); not toShow().

    but it's correct. so thank you very much.

提交回复
热议问题