2012-07-19 52 views
0

我在活動類中做了一個動畫。現在我需要在layout中實現這個活動。所以我打開新的活動類,然後新的xml.then在活動中調用佈局。但它不起作用。使用活動作爲佈局

這是main1.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 
<com.frame.animation.FrameAnimationActivity 
    android:id="@+id/layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"/> 
</LinearLayout> 

以及活動類

public class LaunchActivity extends Activity { 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main1); 
} 
} 

注:我加入Androidmanifest

回答

0

在佈局文件中的每個條目的活動應該是的一個子類視圖。

在XML文件中不能有活動。

將代碼移到從View或ViewGroup繼承的新類。

+0

請你詳細說明一下嗎? – MBMJ 2012-07-19 06:38:43

+0

佈局由View類組成。一個活動顯示一個佈局。 – Brad 2012-07-19 06:51:59

+0

我知道這一點。但我想知道的請不要在我的代碼 – MBMJ 2012-07-19 07:01:56