I am trying to add a LinearLayout using only code to a Activity and I
keep getting as error.  Here is a proof of concept piece of code:

ackage org.syperiorsoft;



import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class ViewTest extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LinearLayout llRoot = (LinearLayout)findViewById(R.id.someid);
        if ( llRoot != null )
        {
                LinearLayout llDetails = new LinearLayout(this);
                llDetails.setLayoutParams(new LayoutParams
(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                llDetails.setGravity(Gravity.LEFT);

                ImageView imEdit = new ImageView(this);
                imEdit.setImageResource(R.drawable.edit);
                imEdit.setLayoutParams(new LayoutParams(32, 32));

                LinearLayout llVert = new LinearLayout(this);
                        llVert.setOrientation(LinearLayout.VERTICAL);
                        llVert.setLayoutParams(new 
LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));

                        llDetails.addView(imEdit);
                        llDetails.addView(llVert);


                        llRoot.addView(llDetails);
        }
    }
}



Here is the stack:

Thread [<3> main] (Suspended (exception RuntimeException))
        LinearLayout.getBaseline() line: 151
        LinearLayout.measureHorizontal(int, int) line: 644
        LinearLayout.onMeasure(int, int) line: 280
        LinearLayout(View).measure(int, int) line: 7115
        LinearLayout(ViewGroup).measureChildWithMargins(View, int, int, int,
int) line: 2875
        LinearLayout.measureChildBeforeLayout(View, int, int, int, int, int)
line: 888
        LinearLayout.measureVertical(int, int) line: 350
        LinearLayout.onMeasure(int, int) line: 278
        LinearLayout(View).measure(int, int) line: 7115
        FrameLayout(ViewGroup).measureChildWithMargins(View, int, int, int,
int) line: 2875
        FrameLayout.onMeasure(int, int) line: 245
        FrameLayout(View).measure(int, int) line: 7115
        LinearLayout.measureVertical(int, int) line: 464
        LinearLayout.onMeasure(int, int) line: 278
        LinearLayout(View).measure(int, int) line: 7115
        PhoneWindow$DecorView(ViewGroup).measureChildWithMargins(View, int,
int, int, int) line: 2875
        PhoneWindow$DecorView(FrameLayout).onMeasure(int, int) line: 245
        PhoneWindow$DecorView(View).measure(int, int) line: 7115
        ViewRoot.performTraversals() line: 698
        ViewRoot.handleMessage(Message) line: 1482
        ViewRoot(Handler).dispatchMessage(Message) line: 99
        Looper.loop() line: 123
        ActivityThread.main(String[]) line: 3948
        Method.invokeNative(Object, Object[], Class, Class[], Class, int,
boolean) line: not available [native method]
        Method.invoke(Object, Object...) line: 521
        ZygoteInit$MethodAndArgsCaller.run() line: 782
        ZygoteInit.main(String[]) line: 540
        NativeStart.main(String[]) line: not available [native method]


I hope someone can help me out, I know I am missing something here.
Thanks to all in advance!

Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to