我已创建自己的ViewGroup。我已经添加了一个小部件到视图中,我从Eclipse Design Editor中得到一个错误(我需要一个预览来获得更快/更好的开发)。自定义ViewGroup
public class MyViewGroup extends LinearLayout {
public MyViewGroup(Context context, AttributeSet attrs) {
super(context, attrs);
this.addView(new EditText(context)); // The Error Line
}
...
}
随着的LayoutParams鸵鸟政策改变什么:
this.addView(new Button(mcontext),
new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<...MyViewGroup android:layout_height="match_parent" android:layout_width="match_parent" android:layout_margin="2dip" android:id="@+id/Token01"> </...MyViewGroup>
</LinearLayout>
我不看它在模拟器上。如果我删除“错误行”,设计器不会出错。什么是我的失败或无法呈现Eclipse Designer?但是为什么我在仿真器/设备上看不到它?我的目标是使用自定义视图和无XML的ViewGroup创建此部分。
我希望你能帮助我,对不起我的英语不好。
谢谢。
感谢您的回答。该守则永远不会运行。可视化编辑器显示错误并且登录模拟器不显示EditText。 – Tim