Advertisement
Guest User

Untitled

a guest
Oct 8th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. public class NguoiDung {
  2. public String username;
  3. public String email;
  4. public String password;
  5. public String ho;
  6. public String ten;
  7. public String sodienthoai;
  8.  
  9. //Constructor
  10. public NguoiDung(String username, String email, String password, String ho, String ten, String sodienthoai) {
  11. this.username = username;
  12. this.email = email;
  13. this.password = password;
  14. this.ho = ho;
  15. this.ten = ten;
  16. this.sodienthoai = sodienthoai;
  17. }
  18.  
  19.  
  20. //Getter Setter
  21. public String getUsername() {
  22. return username;
  23. }
  24.  
  25. public void setUsername(String username) {
  26. this.username = username;
  27. }
  28.  
  29. public String getEmail() {
  30. return email;
  31. }
  32.  
  33. public void setEmail(String email) {
  34. this.email = email;
  35. }
  36.  
  37. public String getPassword() {
  38. return password;
  39. }
  40.  
  41. public void setPassword(String password) {
  42. this.password = password;
  43. }
  44.  
  45. public String getHo() {
  46. return ho;
  47. }
  48.  
  49. public void setHo(String ho) {
  50. this.ho = ho;
  51. }
  52.  
  53. public String getTen() {
  54. return ten;
  55. }
  56.  
  57. public void setTen(String ten) {
  58. this.ten = ten;
  59. }
  60.  
  61. public String getSodienthoai() {
  62. return sodienthoai;
  63. }
  64.  
  65. public void setSodienthoai(String sodienthoai) {
  66. this.sodienthoai = sodienthoai;
  67. }
  68.  
  69. NguoiDung nguoiDung;
  70. textViewHoTen = (TextView) V.findViewById(R.id.textViewHoTen);
  71. @Override
  72. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  73. // Inflate the layout for this fragment
  74. inflater = getActivity().getLayoutInflater();
  75. View V = inflater.inflate(R.layout.tab_tai_khoan_view, container, false);
  76. getData(V, url);
  77. textViewHoTen = (TextView) V.findViewById(R.id.textViewHoTen);
  78. textViewHoTen.setText(nguoiDung.getUsername());
  79. return V;
  80. }
  81.  
  82. private void getData(View V, String url){
  83. RequestQueue requestQueue = Volley.newRequestQueue(V.getContext());
  84. JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, url, null,
  85. new Response.Listener<JSONArray>() {
  86. @Override
  87. public void onResponse(JSONArray response) {
  88. for (int i=0; i<response.length(); i++){
  89. try {
  90. JSONObject object = response.getJSONObject(i);
  91. nguoiDung = new NguoiDung(
  92. object.getString("Username"),
  93. object.getString("Email"),
  94. object.getString("Password"),
  95. object.getString("Ho"),
  96. object.getString("Ten"),
  97. object.getString("SoDienThoai")
  98. );
  99. } catch (JSONException e) {
  100. e.printStackTrace();
  101. }
  102. }
  103. }
  104. },
  105. new Response.ErrorListener() {
  106. @Override
  107. public void onErrorResponse(VolleyError error) {
  108.  
  109. }
  110. }
  111. );
  112. requestQueue.add(jsonArrayRequest);
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement