Why isn't this working?

JonCamilleri

New member
Feb 3, 2015
2
0
0
Visit site
I cannot quite understand why Android Studio complains so much about this code, can you help please as I am still learning?

Java:
package com.example.android.camera2basic;
package com.paad.ch02_manual_layout;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SecondActivity extends Activity {


        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            LinearLayout.LayoutParams lp;
            lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.FILL_PARENT);

            LinearLayout.LayoutParams textViewLP;
            textViewLP = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT);

            LinearLayout ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);

            TextView myTextView = new TextView(this);
            myTextView.setText(getString(R.string.hello));

            ll.addView(myTextView, textViewLP);
            this.addContentView(ll, lp);
        }

    }

Source of reference is Professional Android 4 Application Development ISBN 978-1-118-10227-5, written by Reto Meier, page 38 <link removed>
 
Last edited by a moderator:

Members online

Forum statistics

Threads
943,146
Messages
6,917,510
Members
3,158,843
Latest member
samyblaze