亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

程序一運行就崩潰!求助各位了!

程序一運行就崩潰!求助各位了!

被窩別走 2016-09-13 23:27:00
錯誤提示:09-13 14:59:32.462 7428-7452/com.chen.zhou.myapplication4 E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Process: com.chen.zhou.myapplication4, PID: 7428? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? java.lang.RuntimeException: An error occurred while executing doInBackground()? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.os.AsyncTask$3.done(AsyncTask.java:309)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.util.concurrent.FutureTask.setException(FutureTask.java:223)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.util.concurrent.FutureTask.run(FutureTask.java:242)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.lang.Thread.run(Thread.java:818)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.os.Handler.<init>(Handler.java:200)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.os.Handler.<init>(Handler.java:114)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.app.Activity.<init>(Activity.java:754)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.support.v4.app.BaseFragmentActivityGingerbread.<init>(BaseFragmentActivityGingerbread.java:34)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.support.v4.app.BaseFragmentActivityHoneycomb.<init>(BaseFragmentActivityHoneycomb.java:29)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.support.v4.app.BaseFragmentActivityJB.<init>(BaseFragmentActivityJB.java:29)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.support.v4.app.FragmentActivity.<init>(FragmentActivity.java:75)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.support.v7.app.AppCompatActivity.<init>(AppCompatActivity.java:61)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at com.chen.zhou.myapplication4.ItemBean.<init>(ItemBean.java:8)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at com.chen.zhou.myapplication4.MainActivity.getItemBean(MainActivity.java:58)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at com.chen.zhou.myapplication4.MainActivity.access$000(MainActivity.java:22)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at com.chen.zhou.myapplication4.MainActivity$NewAsyncTask.doInBackground(MainActivity.java:38)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at com.chen.zhou.myapplication4.MainActivity$NewAsyncTask.doInBackground(MainActivity.java:34)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.os.AsyncTask$2.call(AsyncTask.java:295)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.util.concurrent.FutureTask.run(FutureTask.java:237)? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at java.lang.Thread.run(Thread.java:818)?09-13 14:59:33.123 7428-7455/com.chen.zhou.myapplication4 E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f40c7d1a010源碼如下:MainActivityandroid.os.AsyncTaskandroid.support.v7.app.AppCompatActivityandroid.os.Bundleandroid.util.Logandroid.widget.ListVieworg.json.JSONArrayorg.json.JSONExceptionorg.json.JSONObjectjava.io.BufferedInputStreamjava.io.BufferedReaderjava.io.IOExceptionjava.io.InputStreamjava.io.InputStreamReaderjava.io.UnsupportedEncodingExceptionjava.net.URLjava.util.ArrayListjava.util.ListMainActivity?AppCompatActivity?{ ????String?=ListView?(Bundle?savedInstanceState)?{ ????????.onCreate(savedInstanceState)setContentView(R.layout.)=?(ListView)?findViewById(R.id.)NewAsyncTask().execute()} ????String?(InputStream?is){ ????????String?result=InputStreamReader?isr=?String?line={ ????????????isr?=?InputStreamReader(is)BufferedReader?br=BufferedReader(isr)((line=br.readLine())!=){ ????????????????result+=line} ????????}?(UnsupportedEncodingException?e)?{ ????????????e.printStackTrace()}?(IOException?e)?{ ????????????e.printStackTrace()} ????result} ????List<ItemBean>(String?url)?{ ????????List<ItemBean>?itemBeanlist?=?ArrayList<ItemBean>()ItemBean?itemBean{ ????????????String?jsonString?=?readUrl(URL(url).openStream())JSONObject?jsonObject?=?JSONObject(jsonString)JSONArray?jsonArray?=?jsonObject.getJSONArray()(i?=?i?<?i++)?{ ????????????????jsonObject?=?jsonArray.getJSONObject(i)itemBean?=?ItemBean()itemBean.=?jsonObject.getString()itemBean.=?jsonObject.getString()itemBean.=?jsonObject.getString()itemBeanlist.add(itemBean)} ????????}?(IOException?e)?{ ????????????e.printStackTrace()}?(JSONException?e)?{ ????????????e.printStackTrace()} ????????itemBeanlist} ????NewAsyncTask?AsyncTask<StringVoidList<ItemBean>>{ ????????List<ItemBean>?(String...?strings)?{ ????????????getItemBean(strings[])} ????????(List<ItemBean>?itemBeanList)?{ ????????????.onPostExecute(itemBeanList)MyAdapter?adapter=MyAdapter(itemBeanListMainActivity.).setAdapter(adapter)} ????} }ItemBean:android.support.v7.app.AppCompatActivityItemBean??{ ????String?String?String?}MyAdapter:android.content.Contextandroid.view.LayoutInflaterandroid.view.Viewandroid.view.ViewGroupandroid.widget.BaseAdapterandroid.widget.ImageSwitcherandroid.widget.ImageViewandroid.widget.TextViewjava.util.ListMyAdapter?BaseAdapter?{ ????List<ItemBean>?LayoutInflater?Context?MyAdapter(List<ItemBean>?itemBeanListContext?context){ ????????.=itemBeanList=LayoutInflater.(context)} ????()?{ ????????.size()} ????Object?(i)?{ ????????.get(i)} ????(i)?{ ????????i} ????View?(iView?viewViewGroup?viewGroup)?{ ????????ViewHolder?viewHolder=(view==){ ????????????viewHolder=ViewHolder()view=.inflate(R.layout.)viewHolder.=?(ImageView)?view.findViewById(R.id.)viewHolder.=?(TextView)?view.findViewById(R.id.)viewHolder.=?(TextView)?view.findViewById(R.id.)view.setTag(viewHolder)} ????????{ ????????????viewHolder=(ViewHolder)view.getTag()} ????????viewHolder..setText(.get(i).)viewHolder..setText(.get(i).)viewHolder..setImageResource(R.mipmap.)view} ????ViewHolder{ ????????ImageView?TextView?TextView?} }
查看完整描述

1 回答

?
ziom

TA貢獻948條經驗 獲得超1109個贊

異常信息里說的很清楚了:

Caused?by:?java.lang.RuntimeException:?Can't?create?handler?inside?thread?that?has?not?called?Looper.prepare()

不能在子線程創建handler。你看一下你是不是在異步加載的doInBackground()里創建的handler

查看完整回答
2 反對 回復 2016-09-14
  • 被窩別走
    被窩別走
    這個我知道,但我還沒學到handler,看來我得看handler了,而且我是照著視頻來的,哪邊出問題了呢。。。
  • ziom
    ziom
    你說你知道又說你沒學handler,這是什么意思? - -
  • 被窩別走
    被窩別走
    我看得懂那個異常信息,但不知道handler是什么和怎么解決。。
點擊展開后面1
  • 1 回答
  • 0 關注
  • 4553 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號