2016-09-19 59 views
-4
protected void setupView(){ 
// TourGuide can only be setup after all the views is ready and obtain it's position/measurement 
// so when this is the 1st time TourGuide is being added, 
// else block will be executed, and ViewTreeObserver will make TourGuide setup process to be delayed until everything is ready 
// when this is run the 2nd or more times, if block will be executed 
if (ViewCompat.isAttachedToWindow(mHighlightedView)){ 
    startView(); 
} else { 
    final ViewTreeObserver viewTreeObserver = mHighlightedView.getViewTreeObserver(); 
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 
     @Override 
     public void onGlobalLayout() { 
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { 
       //noinspection deprecation 
       mHighlightedView.getViewTreeObserver().removeGlobalOnLayoutListener(this); 
      } else { 
       mHighlightedView.getViewTreeObserver().removeOnGlobalLayoutListener(this); 
      } 
      startView(); 
     } 
    }); 
} 
} 

得到錯誤找不到符號法isAttachedToWindow(查看)

Error:(198, 23) error: cannot find symbol method isAttachedToWindow(View) 

我在Android Studio中使用'com.android.support:appcompat-v7:22.0.1'

+0

編輯您的問題,根據代碼格式化 –

+0

怎麼樣,我使用「com.android.support:appcompat-v7:22.0.1」機器人studio'問題'? –

+0

現在我正在使用編譯'com.android.support:support-v4:24.2.0' –

回答

0

試試這個:

  if(Build.VERSION.SDK_INT == 18){ 
       // Do some stuff 
      } 
      else if (Build.VERSION.SDK_INT == 19) { 
       // Do some stuff 
      } 
      else{ 
       // Do some stuff 
      }