2014-02-17 56 views
-2

我做了一個android應用,但我想開始一個新的活動(.xml)。 通常,當應用程序啓動時,它會顯示直接的activity_main.xml佈局文件。 我不知道這是怎麼回事,所以這是什麼代碼,因爲我知道如何開始一個新的活動。Android應用啓動activity_main.xml

+0

那麼你必須改善你的搜索。有很多教程可用。 –

+0

@ BenjaminStrike normalley你可以編寫意圖代碼 – Amitsharma

+0

我明白這是關於創建一個新的屏幕? http://stackoverflow.com/questions/3690851/android-creating-a-new-activity-in-eclipse – Gimer

回答

0

簡單U都需要在主要活動: -

{ 
(R.layout.main_activity); 
    Intent intent =new Intent(getApplicationContext(),AnotherActivity.class); 
    startActivity(intent); 
} 
and then you have create `AnotherActivity.class 
and insert another layout for AnotherActivity in (R.layout.anotherlayout); 
that solve 
0

您可以指定要使用的setContentView方法在你的活動,以顯示佈局:

setContentView(R.layout.layoutForYourActivity); 

這有你的onCreate方法內到指定

0

通過創建新一項新的活動 - >其他 - > Android的 - > Android的活動

A活性是的.java文件時,.XML只是佈局。 呼叫與

intent = new Intent(main.this, YourActivity.class); 
startActivity(intent); 

新的活動,我建議你做一些基本的教程。