How do I show TextView's in LinearLayout that layed on other Layout?
Posted
by
gelassen
on Stack Overflow
See other posts from Stack Overflow
or by gelassen
Published on 2011-01-01T10:26:20Z
Indexed on
2011/01/07
9:54 UTC
Read the original article
Hit count: 297
Good day.
I have three layouts: first is the root, second and third lie in first. I try add TextView object in third layout and objects had been added in third layout (I saw it in debage mode) but this objects didn't showed on screen.
May be someone know where is the problem?
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/addJokeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
/>
<EditText
android:id="@+id/newJokeEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
protected void initLayout() {
setContentView(R.layout.advanced);
LinearLayout linearLayout = (LinearLayout) getLayoutInflater().inflate(
R.layout.advanced, null);
m_vwJokeEditText = (EditText) findViewById(R.id.newJokeEditText);
m_vwJokeButton = (Button) findViewById(R.id.addJokeButton);
m_vwJokeLayout = (LinearLayout) linearLayout.getChildAt(1);
}
protected void addJoke(Joke joke) {
m_arrJokeList.add(joke);
LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
TextView textView = new TextView(this);
setColor(textView);
textView.setLayoutParams(lparams);
textView.setText(joke.getJoke());
m_vwJokeLayout.addView(textView);
}
© Stack Overflow or respective owner