mkkhedawat
mkkhedawat

Reputation: 1717

dynamic display of test without using textview : Android

Actually I want to show some text using dynamic variable , along with want to take an another input from user so I want a input text thing & send button too.

I googled but every place i am getting that i need to use this kind of code

 TextView textView = new TextView(this);
 textView.setTextSize(20);
 textView.setText("score :"+test+"\n x : 3\n  y : 8");
 setContentView(textView);

But using this full layout becomes textview & i cant add button , if i do , i can't see them on screen .All i see is the text above.

Upvotes: 0

Views: 75

Answers (1)

J David Smith
J David Smith

Reputation: 4810

If I'm reading this correctly, you want to have a layout which is something like this:

<RelativeLayout ....>
    <EditText .... />
    <Button ..... />
    <TextView android:id="@+id/scoreDisplay" ..... />
</RelativeLayout>

Then, in your activity's onCreate:

setContentView(R.layout......);

TextView tv = findViewById(R.id.scoreDisplay);
tv.setTextSize(20);
tv.setText("score :"+test+"\n x : 3\n y : 8");

This will have a layout containing 3 elements (an EditText, a Button, and a TextView).

Upvotes: 3

Related Questions