我用ShowcaseView這樣的:ShowcaseView突出錯誤的項目
ActionItemTarget target = new ActionItemTarget(this, R.id.menu_search);
ShowcaseView sv = new ShowcaseView.Builder(this, true)
.setTarget(target)
.setContentText("Press this to search")
.setStyle(R.style.CustomShowcaseTheme)
.build();
但是當我開始應用第一,ShowcaseView突出home鍵。當我嘗試再次啓動應用程序時,顯示正確的ActionBar項目。 我的應用程序不使用ActionbarSherlock等兼容性庫。
任何想法爲什麼會發生這種情況?
你是什麼意思的「再次啓動應用程序」。你強迫關閉它並打開它,或者你重新打開它調用onPause + onResume?此外,你什麼時候調用這個代碼?因爲'R.id.menu_search'可能當時還沒有可用 – 2014-10-01 15:31:50
@PedroOliveira我在onCreate()中調用它。顯然這是一個錯誤的地方。 – 2014-10-01 15:43:35
使用此代碼的最佳位置將放在onCreateOptionsMenu上,即使在那裏'R.id.menu_search'也不會指向視圖,因爲它尚未被充氣,所以您將不得不找到一種方法來在那裏不使用ID。 – 2014-10-01 15:46:07