2011-12-13 27 views
2

我希望我的用戶能夠選擇幾個可以傳輸到不同頁面的按鈕,如「收藏按鈕」頁面。要做到這一點,我需要從應用程序更改佈局。即使在關閉應用後,我也希望修改後的佈局能夠保留。是否有可能做到這一點?動態更改應用程序中的佈局

+0

SO喲要想讓用戶選擇的東西這將產生在用戶拿起按鈕右側的順序屏幕上的按鈕? – JPM 2011-12-14 17:17:11

+0

JPM,你完全正確 – 2011-12-14 21:19:55

回答

0

對於這個你應該做一些不同的佈局活動。 如果不希望添加更多的活動只是用這樣的:

private void SwitchLayout2() 
{ 
    RelativeLayout Layout1 = (RelativeLayout)findViewById(R.id.layout1); 
    RelativeLayout Layout2 = (RelativeLayout)findViewById(R.id.layout2); 

    // Enable Layout 2 and Disable Layout 1 
    Layout1 .setVisibility(View.GONE); 
    Layout2.setVisibility(View.VISIBLE); 
} 

private void SwitchLayout1() 
{ 
    RelativeLayout Layout1 = (RelativeLayout)findViewById(R.id.layout1); 
    RelativeLayout Layout2 = (RelativeLayout)findViewById(R.id.layout2); 

    // Enable Layout 1 & Disable Layout2 
    Layout1.setVisibility(View.VISIBLE); 
    Layout2.setVisibility(View.GONE); 
}