Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class NguoiDung {
- public String username;
- public String email;
- public String password;
- public String ho;
- public String ten;
- public String sodienthoai;
- //Constructor
- public NguoiDung(String username, String email, String password, String ho, String ten, String sodienthoai) {
- this.username = username;
- this.email = email;
- this.password = password;
- this.ho = ho;
- this.ten = ten;
- this.sodienthoai = sodienthoai;
- }
- //Getter Setter
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getHo() {
- return ho;
- }
- public void setHo(String ho) {
- this.ho = ho;
- }
- public String getTen() {
- return ten;
- }
- public void setTen(String ten) {
- this.ten = ten;
- }
- public String getSodienthoai() {
- return sodienthoai;
- }
- public void setSodienthoai(String sodienthoai) {
- this.sodienthoai = sodienthoai;
- }
- NguoiDung nguoiDung;
- textViewHoTen = (TextView) V.findViewById(R.id.textViewHoTen);
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- inflater = getActivity().getLayoutInflater();
- View V = inflater.inflate(R.layout.tab_tai_khoan_view, container, false);
- getData(V, url);
- textViewHoTen = (TextView) V.findViewById(R.id.textViewHoTen);
- textViewHoTen.setText(nguoiDung.getUsername());
- return V;
- }
- private void getData(View V, String url){
- RequestQueue requestQueue = Volley.newRequestQueue(V.getContext());
- JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, url, null,
- new Response.Listener<JSONArray>() {
- @Override
- public void onResponse(JSONArray response) {
- for (int i=0; i<response.length(); i++){
- try {
- JSONObject object = response.getJSONObject(i);
- nguoiDung = new NguoiDung(
- object.getString("Username"),
- object.getString("Email"),
- object.getString("Password"),
- object.getString("Ho"),
- object.getString("Ten"),
- object.getString("SoDienThoai")
- );
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- }
- }
- );
- requestQueue.add(jsonArrayRequest);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement