第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

從 firebase 獲取名稱時(shí) model_user 中獲取 null - AndroidX

從 firebase 獲取名稱時(shí) model_user 中獲取 null - AndroidX

qq_花開花謝_0 2023-11-01 16:48:39
當(dāng)我在 MainActivity 中時(shí),當(dāng)使用 model_user 從 firebase 設(shè)置用戶名時(shí),我得到 null,這是我使用的代碼//MainActivity.xml<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"tools:context=".MainActivity"><com.google.android.material.appbar.AppBarLayout    android:layout_width="match_parent"    android:layout_height="wrap_content">    <androidx.appcompat.widget.Toolbar        android:id="@+id/Toolbar_Main"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="@color/colorPrimaryDark"        android:theme="@style/Base.ThemeOverlay.AppCompat.Dark.ActionBar">        <de.hdodenhof.circleimageview.CircleImageView            android:layout_width="30dp"            android:layout_height="30dp"            android:id="@+id/profile_image"            android:src="@drawable/profile_blank"/>        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:id="@+id/username"            android:textSize="18sp"            android:layout_marginLeft="25dp"            android:textColor="#fff"            android:textStyle="bold"            android:layout_marginStart="25dp" />    </androidx.appcompat.widget.Toolbar>    <com.google.android.material.tabs.TabLayout        android:id="@+id/tab_layout"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="@color/colorPrimaryDark"        app:tabSelectedTextColor="#fff"        app:tabIndicatorColor="#fff"        app:tabTextColor="#fff"/></com.google.android.material.appbar.AppBarLayout><androidx.viewpager.widget.ViewPager    android:id="@+id/view_pager"    android:layout_width="match_parent"    android:layout_height="match_parent"</LinearLayout>
查看完整描述

2 回答

?
慕工程0101907

TA貢獻(xiàn)1887條經(jīng)驗(yàn) 獲得超5個(gè)贊

刪除 getter-setter 并添加空構(gòu)造函數(shù)


ModelUser.java


  public class ModelUser {

    public String id;

    public String username;

    public String imageURL;


    public ModelUser(String id, String username, String imageURL) {

        this.id = id;

        this.username = username;

        this.imageURL = imageURL;

    }


    public ModelUser() {

    }

    }

嘗試這個(gè)


查看完整回答
反對(duì) 回復(fù) 2023-11-01
?
慕運(yùn)維8079593

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超5個(gè)贊

它不需要?jiǎng)h除 setter getter,


那么從此


public class ModelUser {

private String id;

private String username;

private String imageURL;


public ModelUser(String id, String username, String imageURL) {

    this.id = id;

    this.username = username;

    this.imageURL = imageURL;

}



public String getId() {

    return id;

}


public void setId(String id) {

    this.id = id;

}


public String getUsername() {

    return username;

}


public void setUsername(String username) {

    this.username = username;

}


public String getImageURL() {

    return imageURL;

}


public void setImageURL(String imageURL) {

    this.imageURL = imageURL;

}

}


只需添加一個(gè)空的構(gòu)造函數(shù)即可正常工作:)


public class ModelUser {

public String id;

public String username;

public String imageURL;


public ModelUser(String id, String username, String imageURL) {

    this.id = id;

    this.username = username;

    this.imageURL = imageURL;

}


//Add this

public ModelUser() {

}


public String getId() {

    return id;

}


public void setId(String id) {

    this.id = id;

}


public String getUsername() {

    return username;

}


public void setUsername(String username) {

    this.username = username;

}


public String getImageURL() {

    return imageURL;

}


public void setImageURL(String imageURL) {

    this.imageURL = imageURL;

}

}



查看完整回答
反對(duì) 回復(fù) 2023-11-01
  • 2 回答
  • 0 關(guān)注
  • 160 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)