2013-02-06 28 views
-2

首先,您好。 我有一個瑕疵 - 我想要獲得剛剛從xml文件創建的視圖的頂部像素。 有創建方法。我需要獲取有關佈局的信息,但佈局尚未創建。那麼該怎麼辦>>?!我試圖使用OnStart和OnResume方法,但即使那樣佈局也不會創建。獲取有關剛創建的視圖的信息

protected void onCreate(Bundle savedInstanceState) 
{ 
super.onCreate(savedInstanceState); 
    //full screen 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    //full screen 
    setContentView(R.layout.activity_main); 
    setIdAndConsturtor(); 
    buildLevels(); 
    setIdViews(); 
    setEvents(); 



} 
+0

您是否嘗試過膨脹執行的方法和所有調用的setContentView後的看法? (我猜你知道如何做到這一點)。 – Rigotti

+0

YESS !,在我試過的setIdViews()方法中,但是當我調用方法myview.getBottom()(和底部isn; t零)時,它返回一個零,所以我認爲該視圖還沒有創建YET! ! – user1979976

+0

你能發表這種方法嗎?你調用getBottom() – Rigotti

回答

0

只需撥打這個裏面的方法:

@Override 
public void onWindowFocusChanged(boolean hasFocus) { 
    super.onWindowFocusChanged(hasFocus); 
    //Here you can get put the methods 
    setIdAndConsturtor(); 
    buildLevels(); 
    setIdViews(); 
    setEvents(); 
} 
相關問題