Bir Nepali
Bir Nepali

Reputation: 439

How to add pre defined text in getText() from Textview and show the result

I have textview where user are asked to enter some information and that information is uploaded in Firebase Data Structure and then is Displayed on another activity

Here is the code I'm using to getText from Textview

 etAuthor = (EditText) findViewById(com.nepalpolice.bookbazaar.R.id.editText1);
 String bauthor = etAuthor.getText().toString();

and it does job pretty well.

and it is added to firebase.

But what if I want to add predefined Text like

Author:getText()

Here I have added author. and This will be upudated on Database as well and will Displayed to user instead of Consider Author is

J. K. Rowling

It will show

Author:J.K Rowling

Any help is appreciated.

Thanks in advance.

Upvotes: 0

Views: 152

Answers (3)

Faiizii Awan
Faiizii Awan

Reputation: 1710

String bauthor = "Auther : "+etAuthor.getText().toString(); //use this, '+' use for concatenate

Upvotes: 1

RudRocks05
RudRocks05

Reputation: 13

you can concatenate the desired string, in you case:

String bauthor ="Author:"+etAuthor.getText().toString();

Upvotes: 1

Dipan
Dipan

Reputation: 311

@Bir Nepali, you have to just append while getting the text.

etAuthor = (EditText) findViewById(com.nepalpolice.bookbazaar.R.id.editText1);
String bauthor = "Author:" + etAuthor.getText().toString();

Now you can populate this bauhtor in the view.

Upvotes: 0

Related Questions