简体   繁体   中英

Android set text values of xml layout from java

I am trying to set the values of the android:text from the java code, while the program is running. It is intended to be a schedule program, and after the user logs in, I need to set the values of the text in the listview. The data is being read from a local JSON file, but from there, I am not sure what to do about setting the text values from the code.

Thanks, Androidonly42

You could use an Adapter , and once you have new data from your JSON file, update the model then call notifyDataSetChanged (on the UI thread), to refresh the content of your ListView . Also, have a look here .

You can use ListAdapter. Please have a look at the link below

You can download sample code and have a look http://www.androidhive.info/2011/10/android-listview-tutorial/

List adapter is explained here http://developer.android.com/reference/android/widget/ListAdapter.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM