Reputation: 5259
I am pulling my data from a database and I am using json. What methods should I use in order to print them on texview items of my xml file, because I am little bit confused.
Upvotes: 2
Views: 1988
Reputation: 23952
For example, if your JSONObject is "js"
TextView tx= (TextView) findViewById(R.id.tx);
tx.setText(js.getString("somefield"));
Upvotes: 2
Reputation: 9978
If you have the JSON already wrapped as an java Object, then you can do this to get the textview in your Actvity and set your text:
TextView text = (TextView) findViewById(R.id.myTextView);
text.setText("My JSON text");
myTextView should be the ID fof your textview in your XML layout.
Upvotes: 2
Reputation: 30934
textView.setText(string)
will allow you to put the text into the text view. As we don't know if you were able to extract the needed item or you want to display the full json string, we can't help more.
Upvotes: 1