Android Adding Textview Programmatically
I am trying to add textview in a layout programmatically the textview is added on layout but it's not visible. I have created a method setSelectedContactTextView() which is called
Solution 1:
You may try refering to this code
LinearLayout linearLayout = (LinearLayout)findViewById(R.id.info)
...
linearLayout.addView(valueTV);
also make sure that the layout
params you're creating are LinearLayout.LayoutParams...
Or try this code
LinearLayoutlayout= (LinearLayout) findViewById(R.id.linear);
String[] informations = newString[] { "one", "two", "three" };
TextView informationView;
for (inti=0; i < informations.length; i++) {
Viewline=newView(this);
line.setLayoutParams(newLayoutParams(1, LayoutParams.MATCH_PARENT));
line.setBackgroundColor(0xAA345556);
informationView = newTextView(this);
informationView.setText(informations[i]);
layout.addView(informationView, 0);
layout.addView(line, 1);
}
Post a Comment for "Android Adding Textview Programmatically"