That's because ViewGroup is abstract. You can't make an instance of
it. Instead, you should extend it or use an existing viewgroup such as
linearlayout.
On Apr 7, 3:47 pm, pfife <[EMAIL PROTECTED]> wrote:
> Hi Megha and All,
>
> Thanks much. One more question. I now want to create a ViewGroup
> object with AbsoluteLayout that handles several View objects defined
> with code. Below is the code I wrote. However, I get "Cannot
> instantiate the type ViewGroup" in defining vG. Could I prevail upon
> you to indicate what code needs to be added?
>
> Thanks,
> Pfife
>
> public void onCreate(Bundle icicle) {
> super.onCreate(icicle);
> ViewGroup vG = new ViewGroup(this);
> ImageView iV1 = new ImageView(this);
> AbsoluteLayout mContentView1 = new AbsoluteLayout(this);
> mContentView1.addView(iV1, new
> AbsoluteLayout.LayoutParams( 68, 69, 100, 150));
> iV1.setImageResource(R.drawable.face_c);
> vG.addView(iV1);
> ImageView iV2 = new ImageView(this);
> iV2.setImageResource(R.drawable.face_e);
> AbsoluteLayout mContentView2 = new AbsoluteLayout(this);
> mContentView2.addView(iV2, new
> AbsoluteLayout.LayoutParams( 68, 69, 200, 250));
> vG.addView(iV1);
> vG.addView(iV2);
> setContentView(vG);
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Android Challenge" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-challenge?hl=en
-~----------~----~----~----~------~----~------~--~---