How can I display a TextView containig information from the data base ?
My application displays this information as a Toast but I need it in a TextView.
displayTextView = (TextView)findViewById(R.id.text_view);
Toast.makeText(getBaseContext(), selected.getAdresse(), Toast.LENGTH_LONG).show();
Textview.settext
displayTextView.settext(selected.getAdresse().toString());
displayTextView.setText(selected.getAdresse());
See setText() for more info on developer site.
You mean displayTextView.setText(selected.getAdresse()); ?
Related
I do not know the number. of textview which should be created at runtime. List of Textviews are getting from server. I am creating textviews using below function. Since i am new to android i unable to get text from all textviews. Please suggest me the solution
private void textview(String text)
{
TextView txt_view= new TextView(this);
txt_view.setText(text);
linearLayout.addView(txt_view);
}
Please suggest me the solution i m stuck in getting the text from many textview
Above image is my form, what i want to get text from all views which are created dynamically and store to firebase
add your TextView to HashMap with a unique key
and match your key and get value from map, it will surely help you. after that at time of fetching data use for loop and get data using that unique key
Just get it from your TextView object, like this:
txt_view.getText().toString();
Use same object of TextView to gt text of it. txt_view.getText().toString();
You can get same TextView object by finding childs of LinearLayout.
How about to store them in an ArrayList and iterate over it to get all and maniupulate them afterwards.
ArrayList<TextView> alTextViews = new ArrayList<>();
private void textview(String text) {
TextView txt_view= new TextView(this);
alTextView.add(txt_view);
txt_view.setText(text);
linearLayout.addView(txt_view);
}
with
alTextView.get(0).getText().toString();
you'll get the text
I have a problem with setText(). Although there were many questions about this issue, no single answer solved my problem..
I have one city name saved with SharedPreferences. I get city successfully from SharedPreferences. I want to do the following textview.setText(city) [of course, firstly I determine the textview with findbyId-proper, existing id ]. This is done in onResume() method.
Than I use getText() and System.out.println(getText()) shows exactly the right, saved city. The UI shows the text which was defined at the XML layout of the activity.
I have no idea what to do and how is this even possible. I do not get any errors.
Please, help.
In onResume() method right after super.onResume(); :
city=settings.getString("savedLocation", "null");
textView.setText(city);
System.out.println(city + " " textView.getText());
textView.getText() returns not text string, but object. You should use textView().getText().toString() to retrieve text from a text view
thing is, if i click a button GETDATA - then a new activity starts new.java and i want it to display the contents of my database.
in this new.java i have strings name and id. and i have lined database and this class, such that name and id have the corresponding details that i want to display.
now the ques is, how to display them ?
if i have a
EditText ta;
ta=findViewBy(R.id.edittext1);
ta.setText(name);
should this work ?
it isnt working. also, i dont want user to change the contents and want to make this filed un-editable.
should i use
TextView tf;
ta=findViewBy(R.id.textview1);
tf.setText(name);
?
even this isnt happening.
what is the procedure for this ?
it is done by using append.
TextView ta;
ta=(TextEdit)findViewById(Ri.id.textView1);
String a=getData(1); // goto database, id is 1
ta.append(a);
I am new to android.I have search a lot but doesn't find.In autocompletetextview when no item found in suggestion it should show me message "No result found". But I am not able to do it.
even if this condition not work:
if (!edittext.isPerformingCompletion()){
}
Please help me out.thanks in advance.
How do you fill your AutoCompleteTextView?
I guess that you are using a Adapter and a List of elements.
This way, you can directly search if the text entered by the user is contained in your list.
For example, you can do this on the onTextChanged method of your AutoCompleteTextView.
Show me with some codes of your project so that we can help according to you.
Else take it as sample.
array1 - Array list.
autoText - Text selected in autocomplete textView
if (!array1.contains(autoText)) {
Toast.makeText(getBaseContext(), "No Result Found", Toast.LENGTH_SHORT).show();
}
I have this code for a username field for an Android app. I would like to validate the field to see if it is empty. Here is my code:
View a = findViewById(R.id.authentication);
(a.toString().equals(""))
I am guessing that you cannot use view to get the data entered by the user. What would be the best way to see if these fields are empty?
a.toString() does not do what you think it does.
Use TextView a = (TextView)findViewById(R.id.authentication); (a.getText().equals(""))