Search Results

Search found 1 results on 1 pages for 'cad8'.

Page 1/1 | 1 

  • Creating Linear Layout with TextViews using a for loop

    - by cad8
    Hi all, I was wondering if there is a way to dynamically create an additional linear layout with a textview within a predefined liner layout. THis is my code so you get the gist of what I am asking: LinearLayout MainLL= (LinearLayout) findViewById(R.id.myLayoutId); for(int i=0; i<5; i++) { LinearLayout childLL= new LinearLayout(this); childLL.setOrientation(LinearLayout.VERTICAL); childLL.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); childLL.setGravity(Gravity.LEFT); TextView text = new TextView(this); text.setText("The Value of i is :"i); text.setTextSize(12); text.setGravity(Gravity.LEFT); text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); childLL.addView(text); MainLL.addView(childLL); } My problem is that I am only getting "The Value of i is :0" as the output, i.e. the first instance. Any help would be much appreciated

    Read the article

1