为了账号安全,请及时绑定邮箱和手机立即绑定

点击Image Test按钮闪退

点击Image Test按钮闪退

qkobe 2016-08-04 10:16:10
com.example.qkobe.asynctask; android.graphics.Bitmap; android.graphics.BitmapFactory; android.os.AsyncTask; android.os.Bundle; android.support.v7.app.AppCompatActivity; android.view.View; android.widget.ImageView; android.widget.ProgressBar; java.io.BufferedInputStream; java.io.IOException; java.io.InputStream; java.net.URL; java.net.URLConnection; ImageTest AppCompatActivity {     ImageView ;     ProgressBar ;     String = ;     onCreate(Bundle savedInstanceState) {         .onCreate(savedInstanceState);         = (ImageView)findViewById(R.id.);         = (ProgressBar)findViewById(R.id.);         MyAsyncTask().execute();     }     MyAsyncTask AsyncTask<String,Void,Bitmap>{         onPreExecute() {             .onPreExecute();             .setVisibility(View.);         }         onPostExecute(Bitmap bitmap) {             .onPostExecute(bitmap);             .setImageBitmap(bitmap);             .setVisibility(View.);         }         Bitmap doInBackground(String... params) {             String url = params[];             Bitmap bitmap = ;             URLConnection connection;             InputStream is;             {                 connection = URL(url).openConnection();                 is = connection.getInputStream();                 BufferedInputStream bis = BufferedInputStream(is);                 bitmap = BitmapFactory.(bis);                 is.close();                 bis.close();             }(IOException e){                 e.printStackTrace();             }             bitmap;         }     } }报错为java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ProgressBar.setVisibility(int)' on a null object reference错误行代码为mProgressBar.setVisibility(View.VISIBLE);
查看完整描述

1 回答

?
田心枫

TA贡献1064条经验 获得超383个赞

空指针

查看完整回答
反对 回复 2016-08-04
  • 1 回答
  • 0 关注
  • 1406 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信