У меня есть 2 TextViews, и я хочу добавить их в LinearLayout, но когда я запустил проект, только один TextView был подготовлен.Добавление TextView в LinearLayout в Android
Вот мой код:
public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
TextView textView = new TextView(this);
textView.setText("Thank you, Jesus!");
textView.setTextColor(Color.BLACK);
TextView textView2 = new TextView(this);
textView.setText("Dont give up on me!");
textView.setTextColor(Color.BLACK);
LinearLayout layout = new LinearLayout(this);
layout.setBackgroundColor(Color.WHITE);
layout.addView(textView);
layout.addView(textView2);
setContentView(layout);
}
}
После запуска, textView2 был единственный вид присутствует в LinearLayout.
Может кто-нибудь объяснить мне, что происходит?
О люди! Опс, спасибо за это! –