Results 1 to 1 of 1
  1. #1
    Zarah is offline Senior Member
    Join Date
    Mar 2014
    Rep Power

    Default Creating Layout Programmatically- Questions

    I have a couple of questions from the following code snippet:
    Java Code:
        public void onCreate(Bundle savedInstanceState) {
            // creating LinearLayout
            LinearLayout linLayout = new LinearLayout(this); //****QUESTION 2*********
            // specifying vertical orientation
            // creating LayoutParams  
            LayoutParams linLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); //*****QUESTION 1***
            // set LinearLayout as a root element of the screen 
            setContentView(linLayout, linLayoutParam);
    1. The base class is ViewGroup.LayoutParams, that is LayoutParams is a nested class of ViewGroup. I had also read that it is a static nested class. So why don't we refer to it using the outer class' name and dot notation:

      Java Code:
      ViewGroup.LayoutParams linLayoutParam = new ViewGroup.LayoutParams(...);
    2. In the following statement, what object is "this"?

      Java Code:
      LinearLayout linLayout = new LinearLayout(this);
    Last edited by Zarah; 05-09-2014 at 07:04 PM.

Similar Threads

  1. Replies: 5
    Last Post: 10-16-2012, 01:10 PM
  2. How to programmatically press a key?
    By Sreejith S in forum New To Java
    Replies: 2
    Last Post: 04-21-2012, 04:54 AM
  3. Grid Layout change layout alignment of control s
    By rellicott in forum SWT / JFace
    Replies: 1
    Last Post: 02-13-2012, 05:11 PM
  4. Replies: 12
    Last Post: 02-05-2011, 11:24 AM
  5. Spring Layout questions.
    By rhonig in forum New To Java
    Replies: 0
    Last Post: 02-11-2010, 05:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts