我正在开发一个安卓应用程序。它在我的笔记本电脑上运行良好,但如果我在不同的笔记本电脑或安卓设备上使用相同的源代码,它不会加载某些内容(例如链接到远程 SQL 数据库的列表)。它使用完全相同的代码和软件版本在我的笔记本电脑上加载良好。
这可能是什么原因?
这是我现在得到的错误:
03-21 23:42:20.174: W/dalvikvm(1037): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-21 23:42:20.183: E/AndroidRuntime(1037): FATAL EXCEPTION: main
03-21 23:42:20.183: E/AndroidRuntime(1037): java.lang.NullPointerException
03-21 23:42:20.183: E/AndroidRuntime(1037): at android.widget.PopupWindow.showAtLocation(PopupWindow.java:791)
03-21 23:42:20.183: E/AndroidRuntime(1037): at com.fokrul.justdeals.ActivityTab$2.onItemLongClick(ActivityTab.java:298)
我的第 298 行如下:
lvBooks.setOnItemLongClickListener(new OnItemLongClickListener(){
public boolean onItemLongClick(AdapterView<?> arg0, View view, final int position, long arg3) {
LayoutInflater inflater = (LayoutInflater)ActivityTab.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View viewInflated = inflater.inflate(R.layout.popupfile, null, false);
popup = new PopupWindow(viewInflated, Resizable.getDrawableWidth(getResources(), R.drawable.popup_menu), Resizable.getDrawableHeight(getResources(), R.drawable.popup_menu), true);
popup.setAnimationStyle(R.style.animation_popup);
View lvBooks = null;
<THIS IS LINE 298>>>>> popup.showAtLocation(lvBooks, Gravity.NO_GRAVITY, view.getWidth()/2-Resizable.getDrawableWidth(getResources(), R.drawable.popup_menu)/2, view.getTop()+view.getHeight()/2);
setPopupListeners(viewInflated, position, bid);
return false;
}
});