0

我已经在一个项目上工作了一段时间,通宵工作,这个项目一直在工作,任何我设法摆脱的小错误。

它处于工作状态,我进行了一次生物休息,然后又回到了这个!

04-17 08:42:53.017: E/AndroidRuntime(4779): FATAL EXCEPTION: main
04-17 08:42:53.017: E/AndroidRuntime(4779): java.lang.NullPointerException
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.AbsListView.obtainView(AbsListView.java:2163)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.ListView.makeAndAddView(ListView.java:1831)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.ListView.fillDown(ListView.java:674)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.ListView.fillFromTop(ListView.java:735)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.ListView.layoutChildren(ListView.java:1638)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.AbsListView.onLayout(AbsListView.java:1996)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.View.layout(View.java:14008)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewGroup.layout(ViewGroup.java:4373)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.GridLayout.onLayout(GridLayout.java:1138)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.View.layout(View.java:14008)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewGroup.layout(ViewGroup.java:4373)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1021)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.View.layout(View.java:14008)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewGroup.layout(ViewGroup.java:4373)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.View.layout(View.java:14008)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewGroup.layout(ViewGroup.java:4373)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.View.layout(View.java:14008)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewGroup.layout(ViewGroup.java:4373)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.View.layout(View.java:14008)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewGroup.layout(ViewGroup.java:4373)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1892)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1711)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.Choreographer.doFrame(Choreographer.java:532)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.os.Handler.handleCallback(Handler.java:725)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.os.Looper.loop(Looper.java:137)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at android.app.ActivityThread.main(ActivityThread.java:5234)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at java.lang.reflect.Method.invokeNative(Native Method)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at java.lang.reflect.Method.invoke(Method.java:525)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
04-17 08:42:53.017: E/AndroidRuntime(4779):     at dalvik.system.NativeStart.main(Native Method)

在我休息之前我可能已经改变了一些东西,但这并没有给我太多关于我应该在哪里寻找指针异常的线索......

谁能阐明问题可能出在哪里?

提前致谢...

编辑!!!

public class MenuActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    WindowManager windowManager = getWindowManager();
    Display display = windowManager.getDefaultDisplay();
    if (display.getWidth() > display.getHeight()) {
        setContentView(R.layout.land_activity_menu);
    } else {
        setContentView(R.layout.activity_menu);
    }
}


public void aboutClick(View view) {
    startActivity(new Intent(this, AboutActivity.class));
}

public void newsClick(View view) {
    startActivity(new Intent(this, NewsActivity.class));
}

public void coursesClick(View view) {
    startActivity(new Intent(this, CoursesActivity.class));
}

public void loginClick(View view) {
    startActivity(new Intent(this, LoginActivity.class));
}

然后应用程序在新闻活动启动后立即崩溃......

 public class NewsActivity extends Activity implements OnItemClickListener {

// globals... need to change these?
private ListView listview;
private List<RowItems> rowItems;
final int itemCount = 15;
String newsItemTitles[] = new String[itemCount];
String newsItemDates[] = new String[itemCount];
String newsItemDesc[] = new String[itemCount];
String newsItemHREFS[] = new String[itemCount];
String newsItemPicHREFS[] = new String[itemCount];

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_news);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Start Async for News
    getNewsTask();

}

private void getNewsTask() {
    new getNews().execute();
}

private class getNews extends AsyncTask<Void, Void, Void> {
    private ProgressDialog pd;
    boolean service;
    CustomAdapter adapter;

    @Override
    protected void onPreExecute() {
        pd = new ProgressDialog(NewsActivity.this);
        pd.setTitle("Loading News...");
        pd.setMessage("Loading " + itemCount + " News Items");
        pd.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        pd.dismiss();
                        startActivity(new Intent(NewsActivity.this,
                                MenuActivity.class));
                    }
                });
        pd.show();

    }

我不完全确定什么会导致这里崩溃......

4

1 回答 1

0

正如评论中提到的,如果您在适配器的 getView() 方法中返回 null,您将遇到此问题。如果它为空,请确保创建一个新的 convertView 实例。

于 2013-04-17T08:15:36.920 回答