javaandroid-studiosettext

AndroidStudio/Java: Set Text depending on condition


Trying in AndroidStudio to change the text (id=version) depending on whether I get true or false from settings.isPremium().

How can I realize that?

settings.isPremium() works fine, I still want to know, how to toggle the text content.

if(settings.isPremium()) {

        view.findViewById(R.id.version).setText = "Premium"            

    }
else view.findViewById(R.id.version).setText = "NO Premium"   

Solution

  • Try this:

     if(settings.isPremium()) 
    
         ((TextView) view.findViewById(R.id.version)).setText("Premium"); 
           
    else  
         ((TextView) view.findViewById(R.id.version)).setText("No Premium");