独自の ViewGroup を作成しました。すでにビューにウィジェットを追加していますが、Eclipse デザイン エディターからエラーが発生します (開発を高速化または改善するには、プレビューが必要です)。
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 を使用してこの部分を作成することです。
あなたが私を助けてくれることを願っています。私の悪い英語を申し訳ありません.
ありがとうございました。