2012-07-19 32 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