2017-03-24 26 views
0

在添加材質設計之前,它在工作,但在更改我的佈局(沒有更改imageview)後,我無法顯示圖像。無法顯示來自Firebase的圖像(使用滑動)

public class DownloadFile extends AppCompatActivity { 

    ImageView imageview; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_download_file); 
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 

     FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 
     fab.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View view) { 
       Snackbar.make(view, "Wait for the action", Snackbar.LENGTH_LONG) 
         .setAction("Action", null).show(); 
       yukle(); 
      } 
     }); 


    } 

    public void yukle(){ 
     FirebaseStorage storage = FirebaseStorage.getInstance(); 
     StorageReference storageRef = storage.getReference(); 
     StorageReference riversRef = storageRef.child("images/pic.jpg"); 

     imageview=(ImageView)findViewById(R.id.imageView); 


     Glide.with(this) 
       .using(new FirebaseImageLoader()) 
       .load(riversRef) 
       .into(imageview); 
    } 
} 

我得到以下

03-24 07:41:22.284 22900-22900/com.furkan.profil E/AndroidRuntime: FATAL EXCEPTION: main 
                   Process: com.furkan.profil, PID: 22900 
                   java.lang.IllegalArgumentException: You must pass in a non null View 
                    at com.bumptech.glide.GenericRequestBuilder.into(GenericRequestBuilder.java:678) 
                    at com.bumptech.glide.DrawableRequestBuilder.into(DrawableRequestBuilder.java:448) 
                    at com.furkan.profil.DownloadFile.yukle(DownloadFile.java:58) 
                    at com.furkan.profil.DownloadFile$1.onClick(DownloadFile.java:40) 
                    at android.view.View.performClick(View.java:5198) 
                    at android.view.View$PerformClick.run(View.java:21147) 
                    at android.os.Handler.handleCallback(Handler.java:739) 
                    at android.os.Handler.dispatchMessage(Handler.java:95) 
                    at android.os.Looper.loop(Looper.java:148) 
                    at android.app.ActivityThread.main(ActivityThread.java:5417) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
03-24 07:41:30.213 22900-22994/com.furkan.profil W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found. 

誤差在火力地堡邊,這裏是我的規則

service firebase.storage { 
    match /b/{bucket}/o { 
    match /{allPaths=**} { 
     allow read: if true; 
     allow write: if true; 
    } 
    } 
} 

回答

0

以及您的堆棧跟蹤表明您傳遞滑行的ImageView爲空。所以你在findViewById中設置的參數必須是錯的。確保你傳遞正確的ID,否則發佈你的XML,所以我們有更多的信息。

+0

謝謝,我解決了這個問題。問題是我的imageView沒有任何ID。我給了他身份證,並解決了問題。再次感謝。 –

+0

不客氣:) –

0

,就把這行上您的onCreate

imageview=(ImageView)findViewById(R.id.imageView);