I read this somewhere here and I totally lost it, but could use some assistance.
My app is pulling the column names from sqlite into an array. I want to create a tex
So lets say you have created a linearlayout inside a .xml file like this:
now the code to add 5 textviews dynamically
LinearLayout linearLayout= (LinearLayout)findViewById(R.id.linear); //find the linear layout
linearLayout.removeAllViews(); //add this too
for(int i=0; i<5;i++){ //looping to create 5 textviews
TextView textView= new TextView(this); //dynamically create textview
textView.setLayoutParams(new LinearLayout.LayoutParams( //select linearlayoutparam- set the width & height
ViewGroup.LayoutParams.MATCH_PARENT, 48));
textView.setGravity(Gravity.CENTER_VERTICAL); //set the gravity too
textView.setText("Textview: "+i); //adding text
linearLayout.addView(textView); //inflating :)
}