android安卓handler报空指针错

有2个按钮 一个是扫描一个查询 按扫描可以扫描二维码(二维码包含json信息)然后解析后显示在二维码信息那里 然后点查询 把二维码所含的json信息发送出去 得到返回值显示在返回信息那里 如果我只做查询 解析结果可以正常显示 如果我再点查询就会报一个空指针 说我解析那一步错 如果我不做解析 那发送也正常 有没有大神帮我看看为什么
错误信息
Process: com.abc.smartpos.cash, PID: 25086
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
at com.abc.smartpos.cash.ScanQR.parseJSONWithGSONForQR(ScanQR.java:138)
at com.abc.smartpos.cash.ScanQR$4.handleMessage(ScanQR.java:127)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)

我的代码

    String orderresult;
    Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            orderresult=msg.getData().getString("msg");
                        //单独执行parseJSONWithGSONForQR()正常显示,继续执行查询操作这里报空指针
            parseJSONWithGSONForQR(orderresult);
            responseinfo.setText(msg.getData().getString("JSON"));
        }
    };

//解析扫描得到的JSON数据后设置textview
    public void parseJSONWithGSONForQR(String jsonData) {
        String showorder;
        Gson gson = new Gson();
        List<TransPack> transPackList = gson.fromJson(jsonData, new TypeToken<List<TransPack>>() {
        }.getType());
        for (TransPack transPack : transPackList) {
            showorder="订单号:"+transPack.getId().toString()+"\n"+"意向金:"+transPack.getIntention().toString()+"\n"+"进度款:"+transPack.getProgress().toString()+"\n"+"设计费:"+transPack.getDesign().toString();
            orderinfo.setText(showorder);
        }
    }
//开启新线程
    public void queryOrder(){
        new Thread(){
            public void run(){
                postJson();
            }
        }.start();
    }
//发送JSON并得到返回值,用handler发送
    public String responseJSON;
    public static final String TAG="ScanQR";
    public static final MediaType JSON=MediaType.parse("application/json; charset=utf-8");
    public void postJson(){
        OkHttpClient okHttpClient=new OkHttpClient();
        RequestBody requestBody=RequestBody.create(JSON,orderresult);
        Request request=new Request.Builder()
                .url("http://api.jisuapi.com/iqa/query")
                .post(requestBody)
                .build();
        try{
            Response response=okHttpClient.newCall(request).execute();
            if(response.isSuccessful()){
                Log.i(TAG,response.body().string());
                responseJSON=response.toString();
                Message msg=new Message();
                msg.getData().putString("JSON",responseJSON);
                handler.sendMessage(msg);
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }

图片说明

2个回答

你的jsonData为空

Message msg=new Message();
msg.getData().putString("JSON",responseJSON);
handler.sendMessage(msg);

然后执行这里时候
orderresult=msg.getData().getString("msg");
这个orderresult为空

然后
List transPackList = gson.fromJson(jsonData, new TypeToken>() {
}.getType());
这个jsonData就是传空了

//发送JSON并得到返回值,用handler发送
public String responseJSON;
public static final String TAG="ScanQR";
public static final MediaType JSON=MediaType.parse("application/json; charset=utf-8");
public void postJson(){
OkHttpClient okHttpClient=new OkHttpClient();
RequestBody requestBody=RequestBody.create(JSON,orderresult);
Request request=new Request.Builder()
.url("http://api.jisuapi.com/iqa/query")
.post(requestBody)
.build();
try{
Response response=okHttpClient.newCall(request).execute();
if(response.isSuccessful()){
Log.i(TAG,response.body().string());
responseJSON=response.toString();
Message msg=new Message();
msg.getData().putString("JSO

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
在android中,使用handler出现空指针异常

public class Floating_windowActivity extends Activity { private SliderRelativeLayout sliderLayout = null; private Handler mHandler =new Handler (){ public void handleMessage(Message msg){ Log.i(TAG, "handleMessage : #### " ); if(MSG_LOCK_SUCESS == msg.what){ closeLig(); android.os.Process.killProcess(android.os.Process.myPid()); } super.handleMessage(msg); } }; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sliderLayout = (SliderRelativeLayout)findViewById(R.id.slider_layout); sliderLayout.setMainHandler(mHandler); // 运行到这里报空指针异常,求大神解释。。。 } } public class SliderRelativeLayout extends RelativeLayout { public Handler mainHandler = null; public void setMainHandler(Handler handler){ mainHandler = handler;//activity所在的Handler对象 } private void handleActionUpEvent(MotionEvent event){ Message message = new Message(); message.what = 1; mainHandler.sendMessage(message); } }

android安卓开发 TextView空指针问题怎么解决

我的rmsg已经取到了 System.out.println打印输出也正常 那我设置textView22为什么就报了空指针呢 还是要把textView22放到别的地方去设置 我是点了一个按钮 开始刷卡 然后返回值通过handler发送 然后接收到以后设置成rmsg ``` private TextView textView22; private String rmsg; Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); rmsg=(String)msg.obj; System.out.println("我的卡号是******"+rmsg); textView22.setText(rmsg); } }; ```

android 传递给service数据空指针问题

74行出错 ,nullpointException,帮我解答感激不尽,我想把这个数据传给service public class pdrActivity extends Activity implements View.OnClickListener{ private Button wifi_btn,pdr_btn,photo_btn,other_btn; EditText ed1,ed2,ed3; TextView txt1,txt2,txt3,txt4,txt5; Button startBtn,stopBtn; Spinner spinner; pdrService myservice; pdrService.myBind mybind; float[] sendmessage=new float[3]; Handler handler; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pdr); ed1=(EditText)findViewById(R.id.ed1_pdr); ed2=(EditText)findViewById(R.id.ed2_pdr); ed3=(EditText)findViewById(R.id.ed3_pdr); txt1=(TextView)findViewById(R.id.txt1_pdr); txt2=(TextView)findViewById(R.id.txt2_pdr); txt3=(TextView)findViewById(R.id.txt3_pdr); txt4=(TextView)findViewById(R.id.txt4_pdr); txt5=(TextView)findViewById(R.id.txt5_pdr); spinner=(Spinner)findViewById(R.id.spin_pdr); startBtn=(Button)findViewById(R.id.start_pdr); stopBtn=(Button)findViewById(R.id.stop_pdr); wifi_btn=(Button)findViewById(R.id.btn1_main); photo_btn=(Button)findViewById(R.id.btn3_main); other_btn=(Button)findViewById(R.id.btn4_main); startBtn.setOnClickListener(this); stopBtn.setOnClickListener(this); handler=new Handler(); setData(); // wifi_btn.setOnClickListener(this); // photo_btn.setOnClickListener(this); // other_btn.setOnClickListener(this); } @Override protected void onDestroy() { super.onDestroy(); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.start_pdr: Intent intent=new Intent(this,pdrService.class); bindService(intent,conn,BIND_AUTO_CREATE); handler.postDelayed(runnable,20000); mybind.setData(sendmessage); //error line break; case R.id.stop_pdr: if (myservice.serviceState=="onBind"){ Toast.makeText(this,"service关闭关闭关闭关闭",Toast.LENGTH_SHORT).show(); unbindService(conn); } } } private ServiceConnection conn=new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { System.out.print("service 连接"); mybind=(pdrService.myBind)service; myservice=mybind.getService(); } @Override public void onServiceDisconnected(ComponentName name) { } }; public void setData(){ sendmessage[0]=1; sendmessage[1]=1; sendmessage[2]=1; } Runnable runnable=new Runnable() { @Override public void run() { float[] inf=mybind.getInf(); if(inf==null){ Toast.makeText(pdrActivity.this,"空数据",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(pdrActivity.this,"非空数据",Toast.LENGTH_SHORT).show(); } txt1.setText(String.valueOf(inf[0])); txt2.setText(String.valueOf(inf[1])); txt3.setText(String.valueOf(inf[2])); txt4.setText(String.valueOf(inf[3])); txt5.setText(String.valueOf(inf[4])); handler.postDelayed(this,20000); } }; } 下面的是我的service public class pdrService extends Service implements SensorEventListener{ float[] inf=new float[5]; float[] infmation={0,0,0}; dataExchange dataexchange; private myBind mybind=new myBind(); public static String serviceState=""; proceedThread thread; @Override public void onCreate() { super.onCreate(); if (infmation!=null){ inf[0]=1; inf[1]=1; inf[2]=1; } else{ inf[0]=2; inf[1]=2; inf[2]=2; } thread=new proceedThread(); thread.start(); } @Nullable @Override public IBinder onBind(Intent intent) { serviceState="onBind"; return mybind; } public class myBind extends Binder { public float[] getInf(){ return inf; } public pdrService getService(){ return pdrService.this; } public void setData(float[] data){ pdrService.this.infmation=data; } } private class proceedThread extends Thread{ public Handler myHandler; public void run(){ Looper.prepare(); myHandler=new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); if (msg.what==1){ inf[0]+=1; inf[1]+=1; inf[2]+=1; inf[3]+=1; inf[4]+=1; } } }; Looper.loop(); } } @Override public void onSensorChanged(SensorEvent event) { } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } public void dataListener(dataExchange listener){ this.dataexchange=listener; } }

安卓Adapter空指针,一直解决不了

是这样的。我是在做一个相当于一个手机卫士,里面有通讯录和黑名单两个功能。这个代码是我做的黑名单里的。图片说明 想实现的功能是点黑名单按钮,可以出现这个黑名单的Activity。通讯录做了一个Listview,点通讯录按钮,可以导入系统通讯录,然后设置点击监听,长按item可以发短信,点击可以打电话。 现在的问题是,无论是通讯录还是黑名单,一点按钮就报错,报错的内容就是空指针。不知道怎么解决。哭唧唧。 ![图片说明](https://img-ask.csdn.net/upload/201706/18/1497753680_955031.png) 这个是代码。无论尝试什么方法,都报错空指针。 package com.jinwen.pengu.communication; import android.app.Activity; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; import java.util.List; public class Stop extends Activity { private ListView iv_main; private BlackNumberAdapter adapter; private BlackNumberDao dao; private List data; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv_main = (ListView) findViewById(R.id.iv_main); adapter = new BlackNumberAdapter(); dao = new BlackNumberDao(this); data = dao.getAll(); iv_main.setAdapter(adapter); } public void add(View v){ } class BlackNumberAdapter extends BaseAdapter{ @Override public int getCount() { return data.size(); } @Override public Object getItem(int position) { return data.get(position); } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView ==null){ convertView = View.inflate(Stop.this,android.R.layout.simple_list_item_1,null); } BlackNumber blackNumber = data.get(position); TextView textView = (TextView) convertView.findViewById(android.R.id.text1); textView.setText(blackNumber.getNumber()); return convertView; } } } 错误: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference at com.jinwen.pengu.communication.Stop.onCreate(Stop.java:31)

android adapter提示空指针异常情况

主要代码如下: package com.example.mydreamhero.ActivityManage; import android.app.Activity; import android.app.ActivityManager; import android.content.Context; import android.os.Bundle; import android.os.Debug; import android.widget.ListView; import com.example.mydreamhero.R; import java.util.ArrayList; import java.util.List; /** * Created by 刘 on 2017/3/5. */ public class AMProcessActivity extends Activity { private ListView listView; private List<AMProcessInfo> mAmprocessInfo = null; private ActivityManager manager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.am_main); listView = (ListView) findViewById(R.id.listview_am_process); manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); //提示下面这一行出错 listView.setAdapter(new AMProcessAdapter(this, getRunningprocess())); } private List<AMProcessInfo> getRunningprocess() { mAmprocessInfo = new ArrayList<AMProcessInfo>(); List<ActivityManager.RunningAppProcessInfo> appprocessInfo = manager.getRunningAppProcesses(); for (int i = 0; i < appprocessInfo.size(); i++) { ActivityManager.RunningAppProcessInfo info = appprocessInfo.get(i); int pid = info.pid; int uid = info.uid; String processName = info.processName; int[] memorypid = new int[]{pid}; Debug.MemoryInfo memoryInfo[] = manager.getProcessMemoryInfo(memorypid); int memorySize = memoryInfo[0].getTotalPss(); AMProcessInfo amProcessInfo = new AMProcessInfo(); amProcessInfo.setPid(""+pid); amProcessInfo.setUid(""+uid); amProcessInfo.setMemorySize(memorySize+"KB"); amProcessInfo.setProcessName(processName); mAmprocessInfo.add(amProcessInfo); } return mAmprocessInfo; } }** 出错一次如下: 03/05 23:17:17: Launching app $ adb push F:\androidforGoogle\MyDreamHero\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.example.mydreamhero $ adb shell pm install -r "/data/local/tmp/com.example.mydreamhero" pkg: /data/local/tmp/com.example.mydreamhero Success $ adb shell am start -n "com.example.mydreamhero/com.example.mydreamhero.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Client not ready yet..Waiting for process to come online Waiting for process to come online Connected to process 3275 on device genymotion-genymotion_vbox86p_6_0_160825_141918-192.168.196.101:5555 I/art: Background partial concurrent mark sweep GC freed 1613(300KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 1587KB/2MB, paused 101us total 183.475ms D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.mydreamhero, PID: 3275 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mydreamhero/com.example.mydreamhero.ActivityManage.AMProcessActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) 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) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference at com.example.mydreamhero.ActivityManage.AMProcessActivity.onCreate(AMProcessActivity.java:29) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  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)  我查了好多次都没有找到原因,求大神来不吝解答一下

Android RecyclerView滑动出现空指针异常

ViewPager里面是Fragment然后Fragment里面是RecyclerV但是可以正常显示列表,一旦滑动就会出现异常,这个是垂直方向的 然后里面还嵌套了一个水平方向的网格式RecyclerView没有显示出来!TIME=1429828195000 FINGERPRINT=Xiaomi/cancro_wc_lte/cancro:4.4.4/KTU84P/5.4.24:user/release-keys HARDWARE=qcom UNKNOWN=unknown RADIO=unknown BOARD=MSM8974 versionCode=1 PRODUCT=cancro_wc_lte versionName=1.0 DISPLAY=KTU84P USER=builder HOST=qh-miui-ota-bd56 DEVICE=cancro TAGS=release-keys MODEL=MI 4LTE BOOTLOADER=unknown CPU_ABI=armeabi-v7a CPU_ABI2=armeabi IS_DEBUGGABLE=true ID=KTU84P SERIAL=895f2f74 MANUFACTURER=Xiaomi BRAND=Xiaomi TYPE=user java.lang.NullPointerException at android.support.v4.view.ViewCompat$ICSViewCompatImpl.setAccessibilityDelegate(ViewCompat.java:923) at android.support.v4.view.ViewCompat.setAccessibilityDelegate(ViewCompat.java:1343) at android.support.v7.widget.RecyclerView$Recycler.addViewHolderToRecycledViewPool(RecyclerView.java:3900) at android.support.v7.widget.RecyclerView$Recycler.recycleCachedViewAt(RecyclerView.java:3843) at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:3880) at android.support.v7.widget.RecyclerView$Recycler.recycleView(RecyclerView.java:3804) at android.support.v7.widget.RecyclerView$LayoutManager.removeAndRecycleViewAt(RecyclerView.java:5529) at android.support.v7.widget.LinearLayoutManager.recycleChildren(LinearLayoutManager.java:1143) at android.support.v7.widget.LinearLayoutManager.recycleViewsFromEnd(LinearLayoutManager.java:1218) at android.support.v7.widget.LinearLayoutManager.recycleByLayoutState(LinearLayoutManager.java:1242) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1268) at android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1102) at android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:959) at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:3062) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doframe(Choreographer.java:543) at android.view.Choreographer$frameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5047) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622) at dalvik.system.NativeStart.main(Native Method)

android运行报错求教 空指针异常

报错日志 显示空指针异常 上日志 06-20 19:35:24.264 3122-3122/com.example.wangzhe.ssapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.wangzhe.ssapp, PID: 3122 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.wangzhe.ssapp/com.example.wangzhe.ssapp.Drawer.Device_managment}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.lidroid.xutils.DbUtils com.example.wangzhe.ssapp.My.getDb()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) 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) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.lidroid.xutils.DbUtils com.example.wangzhe.ssapp.My.getDb()' on a null object reference at com.example.wangzhe.ssapp.Drawer.Device_managment.init(Device_managment.java:53) at com.example.wangzhe.ssapp.Drawer.Device_managment.onCreate(Device_managment.java:40) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  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)  ![日志提示位置](https://img-ask.csdn.net/upload/201606/21/1466452017_434017.png) getDb(); package com.example.wangzhe.ssapp; import android.app.Application; import com.lidroid.xutils.DbUtils; import com.lidroid.xutils.DbUtils.DaoConfig; public class My extends Application { private static My mInstance; private DbUtils db; public static My getInstance() { return mInstance; } @Override public void onCreate() { super.onCreate(); mInstance = this; } public DbUtils getDb() { if (db == null) { DaoConfig daoConfig = new DaoConfig(this); daoConfig.setDbName("data.db"); daoConfig.setDbVersion(2); db = DbUtils.create(daoConfig); } return db; } }

Android在动画结束的onAnimationEnd中移除视图报空指针

我在通过按钮删除一个视图,使用了淡出动画,在动画结束的监听中,删除视图removeView,报了空指针,但是用了handler.post后就好了,为什么呢?

android adapter 提示空指针异常

``` public class ContactInfoParser extends Activity { ListView mListView; List<String> contactList = new ArrayList<String>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mListView = (ListView) findViewById(R.id.list_contact); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, contactList); mListView.setAdapter(adapter); readContacts(); } private void readContacts() { Cursor cursor = null; try{ cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); while (cursor.moveToNext()) { String displayname = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String diplaynumber = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); contactList.add(displayname + "\n" + diplaynumber); } }catch (Exception e){ e.printStackTrace(); }finally { if (cursor != null) { cursor.close(); } } } } ``` 上面这段代码从其他activity跳转过来,执行到mListView.setAdapter(adapter);这句话的时候,提示一直报错空指针异常。 报错代码如下: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.liujing.shanzhaisafe/com.liujing.shanzhaisage.fangdaomokuai.dialog.ContactInfoParser}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference at com.liujing.shanzhaisage.fangdaomokuai.dialog.ContactInfoParser.onCreate(ContactInfoParser.java:24)

新建安卓项目,点击layout报空指针异常,一会能用,一会又报错!

没动代码,直接新建的安卓项目!!求解救![图片](https://img-ask.csdn.net/upload/201707/29/1501295860_645346.jpg)

增加个context变量就报空指针异常

这个代码我是复制网上一位博客的,只不过在他的基础上增加个context,目的是想显示 Toast这个东西,但崩溃了,怎么改?新手不懂 ![图片说明](https://img-ask.csdn.net/upload/201702/17/1487280676_887989.png) ![图片说明](https://img-ask.csdn.net/upload/201702/17/1487280727_591317.jpg) EventHandler.java ``` package com.mytest.handlertest; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.util.Log; import android.widget.TextView; import android.widget.Toast; class EventHandler extends Handler { private NoLooperThread noLooperThread; private OwnLooperThread ownLooperThread; private TextView tv; private Context context; public EventHandler(Looper looper) { super(looper); } public EventHandler() { super(); } @Override public void handleMessage(Message msg) { super.handleMessage(msg); Log.e("EventHandler", "当前线程id:------+>"+Thread.currentThread().getId()); Toast.makeText(context, "当前线程id:------+>"+Thread.currentThread().getId(), Toast.LENGTH_SHORT).show(); //可以根据msg.what执行不同的处理,这里没有这么做 switch(msg.what){ case 1: tv.setText((String)msg.obj); break; case 2: tv.setText((String)msg.obj); noLooperThread.stop(); break; case 3: //不能在非主线程的线程里面更新UI,所以这里通过Log打印收到的消息 Log.e("EventHandler", (String)msg.obj); ownLooperThread.stop(); break; default: //不能在非主线程的线程里面更新UI,所以这里通过Log打印收到的消息 Log.e("EventHandler", (String)msg.obj); break; } } } ``` HandlerTest.java ``` package com.mytest.handlertest; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class HandlerTest extends Activity implements OnClickListener { private Button btn1,btn2,btn3,btn4,btn5,btn6; private boolean postRunnable; private EventHandler mHandler; private NoLooperThread noLooperThread; private OwnLooperThread ownLooperThread; private Handler mOtherThreadHandler; private TextView tv; private ReceiveMessageThread receiveMessageThread; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_handler_test); btn1=(Button)findViewById(R.id.b101); btn2=(Button)findViewById(R.id.b102); btn3=(Button)findViewById(R.id.b103); btn4=(Button)findViewById(R.id.b104); btn5=(Button)findViewById(R.id.b105); btn6=(Button)findViewById(R.id.b106); btn1.setOnClickListener(this); btn2.setOnClickListener(this); btn3.setOnClickListener(this); btn4.setOnClickListener(this); btn5.setOnClickListener(this); btn6.setOnClickListener(this); receiveMessageThread=new ReceiveMessageThread(); receiveMessageThread.start(); } @Override public void onClick(View v) { switch(v.getId()){ case R.id.b101: //主线程发送消息给自己 Looper looper; looper = Looper.myLooper(); //get the Main looper related with the main thread //如果不给任何参数的话会用当前线程对应的Looper(这里就是Main Looper)为Handler里面的成员mLooper赋值 mHandler = new EventHandler(looper); //mHandler = new EventHandler(); // 清除整个MessageQueue里的消息 mHandler.removeMessages(0); String obj = "This main thread's message and received by itself!"; //得到Message对象 Message m = mHandler.obtainMessage(1, 1, 1, obj); // 将Message对象送入到main thread的MessageQueue里面 mHandler.sendMessage(m); break; case R.id.b102: //other线程发送消息给主线程 postRunnable = false; noLooperThread = new NoLooperThread(); noLooperThread.start(); break; case R.id.b103: //other thread获取它自己发送的消息 tv.setText("please look at the error level log for other thread received message"); ownLooperThread = new OwnLooperThread(); ownLooperThread.start(); break; case R.id.b104: //other thread通过Post Runnable方式发送消息给主线程 postRunnable = true; noLooperThread = new NoLooperThread(); noLooperThread.start(); break; case R.id.b105: //主线程发送消息给other thread if(null!=mOtherThreadHandler){ tv.setText("please look at the error level log for other thread received message from main thread"); String msgObj = "message from mainThread"; Message mainThreadMsg = mOtherThreadHandler.obtainMessage(1, 1, 1, msgObj); mOtherThreadHandler.sendMessage(mainThreadMsg); } break; case R.id.b106: finish(); break; } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.handler_test, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } ``` NoLooperThread.java ``` package com.mytest.handlertest; import android.content.Context; import android.os.Looper; import android.os.Message; import android.util.Log; import android.widget.TextView; import android.widget.Toast; class NoLooperThread extends Thread{ private Context context; private TextView tv; private boolean postRunnable; private EventHandler mNoLooperThreadHandler; public void run() { Looper myLooper, mainLooper; myLooper = Looper.myLooper(); mainLooper = Looper.getMainLooper(); //这是一个static函数 String obj; if(myLooper == null){ mNoLooperThreadHandler = new EventHandler(mainLooper); obj = "NoLooperThread has no looper and handleMessage function executed in main thread!"; } else { mNoLooperThreadHandler = new EventHandler(myLooper); obj = "This is from NoLooperThread self and handleMessage function executed in NoLooperThread!"; } Toast.makeText(context, obj, Toast.LENGTH_SHORT).show(); mNoLooperThreadHandler.removeMessages(0); if(false == postRunnable){ //send message to main thread Message m = mNoLooperThreadHandler.obtainMessage(2, 1, 1, obj); mNoLooperThreadHandler.sendMessage(m); Log.e("NoLooperThread", "NoLooperThread id:" + this.getId()); }else{ //下面new出来的实现了Runnable接口的对象中run函数是在Main Thread中执行,不是在NoLooperThread中执行 //注意Runnable是一个接口,它里面的run函数被执行时不会再新建一个线程 //您可以在run上加断点然后在eclipse调试中看它在哪个线程中执行 mNoLooperThreadHandler.post(new Runnable(){ @Override public void run() { tv.setText("update UI through handler post runnalbe mechanism!"); // noLooerThread.stop(); } }); } } } ``` OwnLooperThread.java ``` package com.mytest.handlertest; import android.content.Context; import android.os.Looper; import android.os.Message; import android.widget.Toast; class OwnLooperThread extends Thread{ private Context context; private EventHandler mOwnLooperThreadHandler; public void run() { Looper.prepare(); Looper myLooper, mainLooper; myLooper = Looper.myLooper(); mainLooper = Looper.getMainLooper(); //这是一个static函数 String obj; if(myLooper == null){ mOwnLooperThreadHandler = new EventHandler(mainLooper); obj = "OwnLooperThread has no looper and handleMessage function executed in main thread!"; } else { mOwnLooperThreadHandler = new EventHandler(myLooper); obj = "This is from OwnLooperThread self and handleMessage function executed in NoLooperThread!"; } Toast.makeText(context, obj, Toast.LENGTH_SHORT).show(); mOwnLooperThreadHandler.removeMessages(0); //给自己发送消息 Message m = mOwnLooperThreadHandler.obtainMessage(3, 1, 1, obj); mOwnLooperThreadHandler.sendMessage(m); Looper.loop(); } } ``` ReceiveMessageThread.java ``` package com.mytest.handlertest; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.util.Log; import android.widget.Toast; class ReceiveMessageThread extends Thread{ private Handler mOtherThreadHandler; private Context context; public void run() { Looper.prepare(); mOtherThreadHandler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); Log.e("ReceiveMessageThread", (String)msg.obj); Log.e("ReceiveMessageThread","当前线程id:----+>"+Thread.currentThread().getId()); Toast.makeText(context, "当前线程id:----+>"+Thread.currentThread().getId(), Toast.LENGTH_SHORT).show(); } }; Looper.loop(); } } ```

Android自定义控件中为Button设置自定义监听器出现空指针。

Android自定义TopBar中给ImageButton设置自定义点击监听器,当点击ImageButton时在listener处出现NullPointerException。 会出错的地方我在后面写了//TODO 。 请问为什么会出现listener没有被实例化的情况? 还有为什么在MainActivity中使用findViewById实例化TopBar也会出现不能实例化控件的情况? IDE : Android Studio ; Compile Sdk Version : API 23 ; Build Tool Version : 23.0.1 ; Min Sdk Version : API 15 ; Target Sdk Version : API 19 ; 部分代码: #MainActivity.java ``` public class MainActivity extends AppCompatActivity { private TopBar topBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // topBar = (TopBar) findViewById(R.id.topBar); //TODO 这样无法实例化topBar ??? topBar = new TopBar(getApplicationContext(), null); if (topBar == null) { Toast.makeText(MainActivity.this, "NULL", Toast.LENGTH_SHORT).show(); } topBar.setOnTopBarClickListener(new TopBar.OnClickListener() { @Override public void onLeftButtonClick() { Toast.makeText(MainActivity.this, "Left", Toast.LENGTH_SHORT).show(); } @Override public void onRightButtonClick() { Toast.makeText(MainActivity.this, "Right", Toast.LENGTH_SHORT).show(); } }); } } ``` #TopBar.java ``` public class TopBar extends RelativeLayout { private ImageButton ibtLeft; private ImageButton ibtRight; private TextView tvTitle; private OnClickListener listener; public interface OnClickListener { void onLeftButtonClick(); void onRightButtonClick(); } public void setOnTopBarClickListener(OnClickListener listener) { this.listener = listener; } public TopBar(Context context, AttributeSet attrs) { super(context); LayoutInflater.from(context).inflate(R.layout.layout_top_bar, this); ibtLeft = (ImageButton) findViewById(R.id.ibt_left); ibtRight = (ImageButton) findViewById(R.id.ibt_right); tvTitle = (TextView) findViewById(R.id.tv_title); ibtLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getContext(), "leftButton", Toast.LENGTH_SHORT).show(); //Toast可以显示 // listener.onLeftButtonClick(); //TODO NullPointerException 为什么没有实例化listener? } }); ibtRight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { listener.onRightButtonClick(); //TODO NullPointerException } }); } } ``` #logcat输出 ``` 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: FATAL EXCEPTION: main 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: java.lang.NullPointerException 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at com.vder.puzzlegame.ui.TopBar$2.onClick(TopBar.java:55) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at android.view.View.performClick(View.java:4204) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:17355) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:725) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:92) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5041) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 10-14 13:42:14.442 1366-1366/com.vder.puzzlegame E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) ```

Android的GLES20RecordingCanvas空指针的问题

错误是友盟统计提供的,只有这些,没法确定是哪段代码出了问题,所以只想问问大家有没有碰到过类似的问题,给我点提示就好啦,谢谢! 目前看都是出现在4.0以上的版本上,应该跟硬件加速有关。但不知道该怎么解决这个问题。不可能全局关闭硬件加速,代价太高 ``` java.lang.NullPointerException at android.view.GLES20RecordingCanvas.drawBitmap(GLES20RecordingCanvas.java:118) at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:393) at android.widget.ImageView.onDraw(ImageView.java:892) at android.view.View.draw(View.java:11015) at android.view.ViewGroup.drawChild(ViewGroup.java:2971) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573) at android.view.ViewGroup.drawChild(ViewGroup.java:2969) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573) at android.view.View.draw(View.java:11018) at android.widget.FrameLayout.draw(FrameLayout.java:450) at android.widget.ScrollView.draw(ScrollView.java:1525) at android.view.ViewGroup.drawChild(ViewGroup.java:2971) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573) at android.view.ViewGroup.drawChild(ViewGroup.java:2969) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573) at android.view.View.draw(View.java:11018) at android.support.v4.view.ViewPager.draw(ViewPager.java:2092) at android.view.ViewGroup.drawChild(ViewGroup.java:2971) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2573) at android.view.View.getDisplayList(View.java:10452) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2681) at android.view.View.getDisplayList(View.java:10417) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2681) at android.view.View.getDisplayList(View.java:10417) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2681) at android.view.View.getDisplayList(View.java:10417) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2681) at android.view.View.getDisplayList(View.java:10417) at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:851) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2034) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1748) at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2583) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4503) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576) at dalvik.system.NativeStart.main(Native Method) ```

LayoutInflater.from(context) 报空指针异常

这是打印出来的Log: Process: com.hql.rssr, PID: 1905 java.lang.NullPointerException at android.view.LayoutInflater.from(LayoutInflater.java:211) at com.hql.Adapter.FragmentExpanableListViewAdapter.<init>(FragmentExpanableListViewAdapter.java:32) at com.hql.fragment.TechnologyFragment$2.showListView(TechnologyFragment.java:94) at com.hql.fragment.TechnologyFragment$2.handleMessage(TechnologyFragment.java:81) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5045) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) 报错的是这行代码:public FragmentExpanableListViewAdapter(Context context, ArrayList<GroupTitle> Gp, Map<Integer,List<RssItem>> ChildMap) { mInflater = LayoutInflater.from(context); //是这里。。。。。 this.Gp = Gp; this.ChilderMap = ChildMap; list = new ArrayList<RssItem>(); } 我在碎片里面调用的时候是这样子的: adapter = new FragmentExpanableListViewAdapter(getActivity(), title, list); 能运行,数据的加载和显示也没问题,就是在页面切换的时候会偶尔报这个错。我想问一下 这会不会是和多个碎片共用一个适配器有关,因为碎片的布局的样式都一样,只是加载的数据类型不一样 adapter = new FragmentExpanableListViewAdapter(getActivity(), title, list); (就是像这行代码一样 这是里面的title 和list 不一样而已) 我就直接用多个碎片对应一个适配器了 这是怎么回事呢?/d:

急急急 recycleview报一个没有任何提示的空指针

java.lang.NullPointerException at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:1764) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291) at android.view.View.measure(View.java:16497) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:544) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)

安卓listview item单击事件跳转空指针问题

两个activity源码, mainactivity: package com.example.newsclient; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.example.gxfi.entity.News; import com.example.gxfi.service.GetXmlAndParse; import android.R.string; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.SimpleAdapter; public class MainActivity extends Activity { private List listNews; private ListView list; Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub switch (msg.what) { case GetXmlAndParse.PARSESUCCWSS: listNews = (List) msg.obj; initData(); break; } super.handleMessage(msg); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); list = (ListView) findViewById(R.id.list); GetXmlAndParse getXmlAndParse = new GetXmlAndParse(mHandler); getXmlAndParse.getXml(); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub switch (parent.getId()) { case R.id.list: expressItemClick(position);//position 代表你点的哪一个 break; } } private void expressItemClick(int position) { // TODO Auto-generated method stub Intent intent = new Intent(MainActivity.this,NewsActivity.class); Map<String, String> item = (Map<String, String>) list.getAdapter().getItem(position); String essay = item.get("description"); //添加到intent域中 intent.putExtra("description",essay ); startActivity(intent); finish(); }}); } /** * 将解析后的xml填充到ListView */ protected void initData() { // TODO Auto-generated method stub List items = new ArrayList(); for (News news : (List<News>)listNews) { Map item = new HashMap(); item.put("title", news.getTitle()); item.put("description", news.getDescription()); items.add(item); } SimpleAdapter adapter = new SimpleAdapter(this, items, R.layout.news_view, new String[] { "title" }, new int[] { R.id.textView1 }); list.setAdapter(adapter); } } newsactivity: package com.example.newsclient; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.widget.TextView; public class NewsActivity extends Activity { private TextView myTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent(); String value = intent.getStringExtra("description"); myTextView = (TextView) findViewById(R.id.textview2); // myTextView.setText(value); } } 错误: ![图片说明](https://img-ask.csdn.net/upload/201606/19/1466349934_182376.png)

安卓开发Fragment里面空指针问题求大神赐教

报错代码: 12-20 10:21:08.243 4780-4780/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.asus.accuntingapp, PID: 4780 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.asus.accuntingapp/com.example.asus.accuntingapp.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.LinkedList com.example.asus.accuntingapp.RecordDatabaseHelper.getAvaliableDate()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.LinkedList com.example.asus.accuntingapp.RecordDatabaseHelper.getAvaliableDate()' on a null object reference at com.example.asus.accuntingapp.MainViewPagerAdapter.initFragments(MainViewPagerAdapter.java:23) at com.example.asus.accuntingapp.MainViewPagerAdapter.<init>(MainViewPagerAdapter.java:19) at com.example.asus.accuntingapp.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:5933) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)  at android.app.ActivityThread.access$800(ActivityThread.java:144)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5221)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)  相关代码: public class MainViewPagerAdapter extends FragmentPagerAdapter { LinkedList<Mainfragment> fragments=new LinkedList<>(); LinkedList<String> dates=new LinkedList<>(); public MainViewPagerAdapter(FragmentManager fm) { super(fm); initFragments(); } private void initFragments(){ dates = GlobalUtil.getInstance().databaseHelper.getAvaliableDate(); if(!dates.contains(DateUtil.getFormattedDate())){ dates.addLast(DateUtil.getFormattedDate()); } for(String date:dates){ Mainfragment fragment=new Mainfragment(date); fragments.add(fragment); } } public void reload(){ for(Mainfragment fragment:fragments){ fragment.reload(); } } public int getLastIndex(){ return fragments.size()-1; } @Override public Fragment getItem(int position) { return fragments.get(position); } @Override public int getCount() { return fragments.size(); } } public class MainActivity extends AppCompatActivity { private TickerView tickerView; private ViewPager viewPager; private MainViewPagerAdapter pagerAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getSupportActionBar().setElevation(0); viewPager=(ViewPager)findViewById(R.id.view_pager); pagerAdapter=new MainViewPagerAdapter(getSupportFragmentManager()); pagerAdapter.notifyDataSetChanged(); viewPager.setAdapter(pagerAdapter); viewPager.setCurrentItem(pagerAdapter.getLastIndex()); findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent=new Intent(MainActivity.this,AddRecordActivity.class); startActivityForResult(intent,1); } }); GlobalUtil.getInstance().setContext(getApplicationContext()); LinkedList<String> dates=new LinkedList<>(); dates = GlobalUtil.getInstance().databaseHelper.getAvaliableDate(); Log.d("MainActivity","时间"+dates); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); pagerAdapter.reload(); } } 我在别的地方调用这个getAvaliableDate()方法没问题,在MainViewPagerAdapter类里面的initFragments()方法里面调用getAvaliableDate()就会报空指针。我不知道为什么,望大神赐教!

安卓eclipse 空指针错误

java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.itcast.smssender/cn.itcast.smssender.SelectContactActivity}: java.lang.NullPointerException 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.app.ActivityThread.access$800(ActivityThread.java:135) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.os.Handler.dispatchMessage(Handler.java:102) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.os.Looper.loop(Looper.java:136) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.app.ActivityThread.main(ActivityThread.java:5017) 07-27 22:44:34.566: E/AndroidRuntime(2117): at java.lang.reflect.Method.invokeNative(Native Method) 07-27 22:44:34.566: E/AndroidRuntime(2117): at java.lang.reflect.Method.invoke(Method.java:515) 07-27 22:44:34.566: E/AndroidRuntime(2117): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 07-27 22:44:34.566: E/AndroidRuntime(2117): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 07-27 22:44:34.566: E/AndroidRuntime(2117): at dalvik.system.NativeStart.main(Native Method) 07-27 22:44:34.566: E/AndroidRuntime(2117): Caused by: java.lang.NullPointerException 07-27 22:44:34.566: E/AndroidRuntime(2117): at cn.itcast.smssender.SelectContactActivity$MyAdapter.getCount(SelectContactActivity.java:32) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.widget.ListView.setAdapter(ListView.java:480) 07-27 22:44:34.566: E/AndroidRuntime(2117): at cn.itcast.smssender.SelectContactActivity.onCreate(SelectContactActivity.java:26) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.app.Activity.performCreate(Activity.java:5231) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 07-27 22:44:34.566: E/AndroidRuntime(2117): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 07-27 22:44:34.566: E/AndroidRuntime(2117): ... 11 more ![![图片说明](https://img-ask.csdn.net/upload/201607/28/1469674088_627078.png)) ![图片说明](https://img-ask.csdn.net/upload/201607/28/1469674135_218055.png) lv也没啥问题啊 说是空指针 网上说 布局定义的时候以前是android::name 改成id就行了 我本来就是ID啊求大神看看咋回事 改了半天也不成

handler处理2个setText怎么弄 报空指针

我有2个按钮 先点扫描 然后得到二维码内容 显示在二维码信息那里(二维码本身就是JSON格式) 然后点查询 把二维码内容发送出去 得到返回值 显示在返回信息那里 2个方法的返回值都是通过handler发送然后再获取msg 再setText 然后我如果显示了二维码信息 再点查询的话就会退回上一级 报空指针 如果我单扫描二维码 不显示出来(还是获得了二维码信息 仅不setText) 那我点查询就可以显示返回值 请问要怎么解决 让我显示了二维码信息后还是可以显示返回值 新手小白。。。 ``` String orderresult; Handler handler = new Handler() { public void handleMessage(Message msg) { super.handleMessage(msg); orderresult=msg.getData().getString("msg"); parseJSONWithGSONForQR(orderresult); responseinfo.setText(msg.getData().getString("JSON")); } }; public void parseJSONWithGSONForQR(String jsonData) { String showorder; Gson gson = new Gson(); List<TransPack> transPackList = gson.fromJson(jsonData, new TypeToken<List<TransPack>>() { }.getType()); for (TransPack transPack : transPackList) { showorder="订单号:"+transPack.getId().toString()+"\n"+"意向金:"+transPack.getIntention().toString()+"\n"+"进度款:"+transPack.getProgress().toString()+"\n"+"设计费:"+transPack.getDesign().toString(); orderinfo.setText(showorder); } } public void queryOrder(){ new Thread(){ public void run(){ postJson(); } }.start(); } public String responseJSON; public static final String TAG="ScanQR"; public static final MediaType JSON=MediaType.parse("application/json; charset=utf-8"); public void postJson(){ OkHttpClient okHttpClient=new OkHttpClient(); RequestBody requestBody=RequestBody.create(JSON,orderresult); Request request=new Request.Builder() .url("http://api.jisuapi.com/iqa/query") .post(requestBody) .build(); try{ Response response=okHttpClient.newCall(request).execute(); if(response.isSuccessful()){ Log.i(TAG,response.body().string()); responseJSON=response.toString(); Message msg=new Message(); msg.getData().putString("JSON",responseJSON); handler.sendMessage(msg); } }catch (IOException e){ e.printStackTrace(); } } ```

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

课程主要面向嵌入式Linux初学者、工程师、学生 主要从一下几方面进行讲解: 1.linux学习路线、基本命令、高级命令 2.shell、vi及vim入门讲解 3.软件安装下载、NFS、Samba、FTP等服务器配置及使用

我以为我对Mysql事务很熟,直到我遇到了阿里面试官

太惨了,面试又被吊打

Python代码实现飞机大战

文章目录经典飞机大战一.游戏设定二.我方飞机三.敌方飞机四.发射子弹五.发放补给包六.主模块 经典飞机大战 源代码以及素材资料(图片,音频)可从下面的github中下载: 飞机大战源代码以及素材资料github项目地址链接 ————————————————————————————————————————————————————————— 不知道大家有没有打过飞机,喜不喜欢打飞机。当我第一次接触这个东西的时候,我的内心是被震撼到的。第一次接触打飞机的时候作者本人是身心愉悦的,因为周边的朋友都在打飞机, 每

Python数据分析与挖掘

92讲视频课+16大项目实战+源码+¥800元课程礼包+讲师社群1V1答疑+社群闭门分享会=99元 &nbsp; 为什么学习数据分析? &nbsp; &nbsp; &nbsp; 人工智能、大数据时代有什么技能是可以运用在各种行业的?数据分析就是。 &nbsp; &nbsp; &nbsp; 从海量数据中获得别人看不见的信息,创业者可以通过数据分析来优化产品,营销人员可以通过数据分析改进营销策略,产品经理可以通过数据分析洞察用户习惯,金融从业者可以通过数据分析规避投资风险,程序员可以通过数据分析进一步挖掘出数据价值,它和编程一样,本质上也是一个工具,通过数据来对现实事物进行分析和识别的能力。不管你从事什么行业,掌握了数据分析能力,往往在其岗位上更有竞争力。 &nbsp;&nbsp; 本课程共包含五大模块: 一、先导篇: 通过分析数据分析师的一天,让学员了解全面了解成为一个数据分析师的所有必修功法,对数据分析师不在迷惑。 &nbsp; 二、基础篇: 围绕Python基础语法介绍、数据预处理、数据可视化以及数据分析与挖掘......这些核心技能模块展开,帮助你快速而全面的掌握和了解成为一个数据分析师的所有必修功法。 &nbsp; 三、数据采集篇: 通过网络爬虫实战解决数据分析的必经之路:数据从何来的问题,讲解常见的爬虫套路并利用三大实战帮助学员扎实数据采集能力,避免没有数据可分析的尴尬。 &nbsp; 四、分析工具篇: 讲解数据分析避不开的科学计算库Numpy、数据分析工具Pandas及常见可视化工具Matplotlib。 &nbsp; 五、算法篇: 算法是数据分析的精华,课程精选10大算法,包括分类、聚类、预测3大类型,每个算法都从原理和案例两个角度学习,让你不仅能用起来,了解原理,还能知道为什么这么做。

如何在虚拟机VM上使用串口

在系统内核开发中,经常会用到串口调试,利用VMware的Virtual Machine更是为调试系统内核如虎添翼。那么怎么搭建串口调试环境呢?因为最近工作涉及到这方面,利用强大的google搜索和自己

程序员的兼职技能课

获取讲师答疑方式: 在付费视频第一节(触摸命令_ALL)片头有二维码及加群流程介绍 限时福利 原价99元,今日仅需39元!购课添加小助手(微信号:csdn590)按提示还可领取价值800元的编程大礼包! 讲师介绍: 苏奕嘉&nbsp;前阿里UC项目工程师 脚本开发平台官方认证满级(六级)开发者。 我将如何教会你通过【定制脚本】赚到你人生的第一桶金? 零基础程序定制脚本开发课程,是完全针对零脚本开发经验的小白而设计,课程内容共分为3大阶段: ①前期将带你掌握Q开发语言和界面交互开发能力; ②中期通过实战来制作有具体需求的定制脚本; ③后期将解锁脚本的更高阶玩法,打通任督二脉; ④应用定制脚本合法赚取额外收入的完整经验分享,带你通过程序定制脚本开发这项副业,赚取到你的第一桶金!

MFC一站式终极全套课程包

该套餐共包含从C小白到C++到MFC的全部课程,整套学下来绝对成为一名C++大牛!!!

C++语言基础视频教程

C++语言基础视频培训课程:本课与主讲者在大学开出的程序设计课程直接对接,准确把握知识点,注重教学视频与实践体系的结合,帮助初学者有效学习。本教程详细介绍C++语言中的封装、数据隐藏、继承、多态的实现等入门知识;主要包括类的声明、对象定义、构造函数和析构函数、运算符重载、继承和派生、多态性实现等。 课程需要有C语言程序设计的基础(可以利用本人开出的《C语言与程序设计》系列课学习)。学习者能够通过实践的方式,学会利用C++语言解决问题,具备进一步学习利用C++开发应用程序的基础。

北京师范大学信息科学与技术学院笔试10复试真题

北京师范大学信息科学与技术学院笔试,可以更好的让你了解北师大该学院的复试内容,获得更好的成绩。

深度学习原理+项目实战+算法详解+主流框架(套餐)

深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

网络工程师小白入门--【思科CCNA、华为HCNA等网络工程师认证】

本课程适合CCNA或HCNA网络小白同志,高手请绕道,可以直接学习进价课程。通过本预科课程的学习,为学习网络工程师、思科CCNA、华为HCNA这些认证打下坚实的基础! 重要!思科认证2020年2月24日起,已启用新版认证和考试,包括题库都会更新,由于疫情原因,请关注官网和本地考点信息。题库网络上很容易下载到。

Python界面版学生管理系统

前不久上传了一个控制台版本的学生管理系统,这个是Python界面版学生管理系统,这个是使用pycharm开发的一个有界面的学生管理系统,基本的增删改查,里面又演示视频和完整代码,有需要的伙伴可以自行下

软件测试2小时入门

本课程内容系统、全面、简洁、通俗易懂,通过2个多小时的介绍,让大家对软件测试有个系统的理解和认识,具备基本的软件测试理论基础。 主要内容分为5个部分: 1 软件测试概述,了解测试是什么、测试的对象、原则、流程、方法、模型;&nbsp; 2.常用的黑盒测试用例设计方法及示例演示;&nbsp; 3 常用白盒测试用例设计方法及示例演示;&nbsp; 4.自动化测试优缺点、使用范围及示例‘;&nbsp; 5.测试经验谈。

Tomcat服务器下载、安装、配置环境变量教程(超详细)

未经我的允许,请不要转载我的文章,在此郑重声明!!! 请先配置安装好Java的环境,若没有安装,请参照我博客上的步骤进行安装! 安装Java环境教程https://blog.csdn.net/qq_40881680/article/details/83585542 Tomcat部署Web项目(一)·内嵌https://blog.csdn.net/qq_40881680/article/d...

2019数学建模A题高压油管的压力控制 省一论文即代码

2019数学建模A题高压油管的压力控制省一完整论文即详细C++和Matlab代码,希望对同学们有所帮助

图书管理系统(Java + Mysql)我的第一个完全自己做的实训项目

图书管理系统 Java + MySQL 完整实训代码,MVC三层架构组织,包含所有用到的图片资源以及数据库文件,大三上学期实训,注释很详细,按照阿里巴巴Java编程规范编写

linux下利用/proc进行进程树的打印

在linux下利用c语言实现的进程树的打印,主要通过/proc下的目录中的进程文件,获取status中的进程信息内容,然后利用递归实现进程树的打印

微信小程序开发实战之番茄时钟开发

微信小程序番茄时钟视频教程,本课程将带着各位学员开发一个小程序初级实战类项目,针对只看过官方文档而又无从下手的开发者来说,可以作为一个较好的练手项目,对于有小程序开发经验的开发者而言,可以更好加深对小程序各类组件和API 的理解,为更深层次高难度的项目做铺垫。

[已解决]踩过的坑之mysql连接报“Communications link failure”错误

目录 前言 第一种方法: 第二种方法 第三种方法(适用于项目和数据库在同一台服务器) 第四种方法 第五种方法(项目和数据库不在同一台服务器) 总结 前言 先给大家简述一下我的坑吧,(我用的是mysql,至于oracle有没有这样的问题,有心的小伙伴们可以测试一下哈), 在自己做个javaweb测试项目的时候,因为买的是云服务器,所以数据库连接的是用ip地址,用IDE开发好...

人工智能-计算机视觉实战之路(必备算法+深度学习+项目实战)

系列课程主要分为3大阶段:(1)首先掌握计算机视觉必备算法原理,结合Opencv进行学习与练手,通过实际视项目进行案例应用展示。(2)进军当下最火的深度学习进行视觉任务实战,掌握深度学习中必备算法原理与网络模型架构。(3)结合经典深度学习框架与实战项目进行实战,基于真实数据集展开业务分析与建模实战。整体风格通俗易懂,项目驱动学习与就业面试。 建议同学们按照下列顺序来进行学习:1.Python入门视频课程 2.Opencv计算机视觉实战(Python版) 3.深度学习框架-PyTorch实战/人工智能框架实战精讲:Keras项目 4.Python-深度学习-物体检测实战 5.后续实战课程按照自己喜好选择就可以

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

机器学习初学者必会的案例精讲

通过六个实际的编码项目,带领同学入门人工智能。这些项目涉及机器学习(回归,分类,聚类),深度学习(神经网络),底层数学算法,Weka数据挖掘,利用Git开源项目实战等。

Python数据分析师-实战系列

系列课程主要包括Python数据分析必备工具包,数据分析案例实战,核心算法实战与企业级数据分析与建模解决方案实战,建议大家按照系列课程阶段顺序进行学习。所有数据集均为企业收集的真实数据集,整体风格以实战为导向,通俗讲解Python数据分析核心技巧与实战解决方案。

YOLOv3目标检测实战系列课程

《YOLOv3目标检测实战系列课程》旨在帮助大家掌握YOLOv3目标检测的训练、原理、源码与网络模型改进方法。 本课程的YOLOv3使用原作darknet(c语言编写),在Ubuntu系统上做项目演示。 本系列课程包括三门课: (1)《YOLOv3目标检测实战:训练自己的数据集》 包括:安装darknet、给自己的数据集打标签、整理自己的数据集、修改配置文件、训练自己的数据集、测试训练出的网络模型、性能统计(mAP计算和画出PR曲线)和先验框聚类。 (2)《YOLOv3目标检测:原理与源码解析》讲解YOLOv1、YOLOv2、YOLOv3的原理、程序流程并解析各层的源码。 (3)《YOLOv3目标检测:网络模型改进方法》讲解YOLOv3的改进方法,包括改进1:不显示指定类别目标的方法 (增加功能) ;改进2:合并BN层到卷积层 (加快推理速度) ; 改进3:使用GIoU指标和损失函数 (提高检测精度) ;改进4:tiny YOLOv3 (简化网络模型)并介绍 AlexeyAB/darknet项目。

2021考研数学张宇基础30讲.pdf

张宇:博士,全国著名考研数学辅导专家,教育部“国家精品课程建设骨干教师”,全国畅销书《张宇高等数学18讲》《张宇线性代数9讲》《张宇概率论与数理统计9讲》《张宇考研数学题源探析经典1000题》《张宇考

三个项目玩转深度学习(附1G源码)

从事大数据与人工智能开发与实践约十年,钱老师亲自见证了大数据行业的发展与人工智能的从冷到热。事实证明,计算机技术的发展,算力突破,海量数据,机器人技术等,开启了第四次工业革命的序章。深度学习图像分类一直是人工智能的经典任务,是智慧零售、安防、无人驾驶等机器视觉应用领域的核心技术之一,掌握图像分类技术是机器视觉学习的重中之重。针对现有线上学习的特点与实际需求,我们开发了人工智能案例实战系列课程。打造:以项目案例实践为驱动的课程学习方式,覆盖了智能零售,智慧交通等常见领域,通过基础学习、项目案例实践、社群答疑,三维立体的方式,打造最好的学习效果。

DirectX修复工具V4.0增强版

DirectX修复工具(DirectX Repair)是一款系统级工具软件,简便易用。本程序为绿色版,无需安装,可直接运行。 本程序的主要功能是检测当前系统的DirectX状态,如果发现异常则进行修复

期末考试评分标准的数学模型

大学期末考试与高中的考试存在很大的不同之处,大学的期末考试成绩是主要分为两个部分:平时成绩和期末考试成绩。平时成绩和期末考试成绩总分一般为一百分,然而平时成绩与期末考试成绩所占的比例不同会导致出现不同

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂

c语言项目开发实例

十个c语言案例 (1)贪吃蛇 (2)五子棋游戏 (3)电话薄管理系统 (4)计算器 (5)万年历 (6)电子表 (7)客户端和服务器通信 (8)潜艇大战游戏 (9)鼠标器程序 (10)手机通讯录系统

相关热词 c#中如何设置提交按钮 c#帮助怎么用 c# 读取合并单元格的值 c#带阻程序 c# 替换span内容 c# rpc c#控制台点阵字输出 c#do while循环 c#调用dll多线程 c#找出两个集合不同的
立即提问