【发布时间】:2014-11-28 11:11:30
【问题描述】:
我在将布局加载到活动时遇到错误。请看下面的代码 我的 xml 布局文件 -
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<com.xyz.FeatureTop
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".35" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:gravity="center"
android:text="Hello Feature Top"
android:textColor="@android:color/black" />
</com.xyz.FeatureTop>
<com.xyz.Middle
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".35" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:gravity="center"
android:text="Hello Feature Middle"
android:textColor="@android:color/black" />
</com.xyz.Middle>
<com.xyz.FeatureBottom
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".3" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:gravity="center"
android:text="Hello Feature Bottom"
android:textColor="@android:color/black" />
</com.xyz.FeatureBottom>
</LinearLayout>
下面是我的课-
public class Xyz extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
public class FeatureTop extends LinearLayout implements
IndustryCollectionDetailsListener {
public FeatureTop(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public FeatureTop(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FeatureTop(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void featureTopDownloadSuccess() {
// TODO Auto-generated method stub
}
@Override
public void featureTopDownloadFail() {
// TODO Auto-generated method stub
}
@Override
public void featureBottomDownloadSuccess() {
// TODO Auto-generated method stub
}
@Override
public void featureBottomDownloadFail() {
// TODO Auto-generated method stub
}
@Override
public void middleDownloadSuccess() {
// TODO Auto-generated method stub
}
@Override
public void middleDownloadFail() {
// TODO Auto-generated method stub
}
}
public class FeatureBottom extends LinearLayout implements
IndustryCollectionDetailsListener {
public FeatureBottom(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public FeatureBottom(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FeatureBottom(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void featureTopDownloadSuccess() {
// TODO Auto-generated method stub
}
@Override
public void featureTopDownloadFail() {
// TODO Auto-generated method stub
}
@Override
public void featureBottomDownloadSuccess() {
// TODO Auto-generated method stub
}
@Override
public void featureBottomDownloadFail() {
// TODO Auto-generated method stub
}
@Override
public void middleDownloadSuccess() {
// TODO Auto-generated method stub
}
@Override
public void middleDownloadFail() {
// TODO Auto-generated method stub
}
}
public class Middle extends LinearLayout implements
IndustryCollectionDetailsListener {
public Middle(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public Middle(Context context, AttributeSet attrs) {
super(context, attrs);
}
public Middle(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void featureTopDownloadSuccess() {
// TODO Auto-generated method stub
}
@Override
public void featureTopDownloadFail() {
// TODO Auto-generated method stub
}
@Override
public void featureBottomDownloadSuccess() {
// TODO Auto-generated method stub
}
@Override
public void featureBottomDownloadFail() {
// TODO Auto-generated method stub
}
@Override
public void middleDownloadSuccess() {
// TODO Auto-generated method stub
}
@Override
public void middleDownloadFail() {
// TODO Auto-generated method stub
}
}
} 我不知道这个错误。我在xml中缺少任何属性吗?我是安卓开发新手 提前致谢。
【问题讨论】:
-
-_- 显示堆栈跟踪并显示第 28 行
-
in XML
com.xyz.Xyz.Middle-> 你的包,点,类,点,内部类? -
堆栈跟踪 - 11-28 16:28:42.604: E/AndroidRuntime(6324): java.lang.RuntimeException: Unable to start activity ComponentInfo: android.view.InflateException: Binary XML file line # 28:膨胀类 com.xyz.FeatureTop 时出错,第 28 行是
标签: android xml android-layout android-inflate