Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

add dynamic view in android from xml

// Parent layout
LinearLayout parentLayout = (LinearLayout)findViewById(R.id.layout);

// Layout inflater
LayoutInflater layoutInflater = getLayoutInflater();
View view;

for (int i = 1; i < 101; i++){
    // Add the text layout to the parent layout
    view = layoutInflater.inflate(R.layout.text_layout, parentLayout, false);

    // In order to get the view we have to use the new view with text_layout in it
    TextView textView = (TextView)view.findViewById(R.id.text);
    textView.setText("Row " + i);

    // Add the text view to the parent layout
    parentLayout.addView(textView);
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to come from 2nd fragment to first fragment android 
Java :: remove activity from recent list android 
Java :: java jackson optional 
Java :: Changing or Replacing Elements in java map 
Java :: jdbc insert example from input values 
Java :: hello world in bukkit 
Java :: JAVA CHAR TO keyevents 
Java :: how to make a java lex analyzer 
Java :: how to count an replace string in java 
Java :: create a file in java in user home 
Java :: java minimize all windows 
Java :: antlr TestRig in java program 
Java :: geometric primitive 
Java :: java switch expression produce result 
Java :: java program to print hexadecimal to decimal number conversion 
Java :: jakarta allow cross origins 
Java :: can you automate mouseclicks with java 
Java :: how to create a udp protocol for transfer a big quantity of files java 
Java :: firebase timestamp to textview 
Java :: Based on the method exampleMethod, what is the return type of the method? 
Java :: kano magic wand 
Java :: how to reinstall nginuity 
Java :: Write program for problem 1 such that every regex runs as its own thread in java 
Java :: constraints in Grails 
Java :: multiple recyclerview not scrolling bottom sheet 
Java :: gc algorithms java 8 
Java :: how to get listview data, TextView 
Java :: java 8 if else in one statement 
Java :: Java Remove EnumSet Elements 
Java :: prevent creating instance of singleton from thread 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =