title: Android Java While loop in Handler not executing
body: <p>I have 6 string to show in a <code>textview</code> in order. But some of the strings are empty and I  want my program to detect empty strings, wait 1 sec for each empty string detection and then continue to next text.
  I tried to do it with using Handler and while codes but I failed, any help would be appreciated.</p>
  
  <pre><code>TextView Textview1; 
  int str[] = {R.string.str1,R.string.str2,R.string.str3,R.string.str4,R.string.str5,R.string.str6};
  int CurrentText = 0;    
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Textview1 = (TextView)findViewById(R.id.textview1);
      Button button = (Button)findViewById(R.id.button);
      button.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              Textview1.setText(str[CurrentText]);
              String crnt = (String) getText(str[CurrentText]);
              CurrentText++;              
  
              if(crnt.equals("empty")){                   
                  Handler loop = new Handler();
                  loop.postDelayed(new Runnable() {
  
                      @Override
                      public void run() {
                          // TODO Auto-generated method stub                          
                          String crnt2 = (String) getText(str[CurrentText]);
                          while(crnt2.equals("empty")){                               
                              CurrentText++;
                              Textview1.setText(str[CurrentText]);
                              crnt2 = (String) getText(str[CurrentText]);                             
                          }                           
                      }
                  }, 1000);
              }
  </code></pre>