English 中文(简体)
Strange Nullpointer Exception when seeking to rec LinearLayout
原标题:Strange NullpointerException when trying to retrieve LinearLayout

This is a bit of a shot in the dark, but perhaps I m making an obvious mistake; I have a LinearLayout defined in my main.xml, with an id "@+id/imageListContainer". There is nothing else in my main.xml, and the LinearLayout is completely plain (As eclipse inserts it for you from the GUI editor).

    <LinearLayout
        android:id="@+id/imageListContainer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
    </LinearLayout>

我然后想用这部法律,积极充实线性。

LinearLayout imageContainer = (LinearLayout)findViewById(R.id.imageListContainer);

转自Create(电话)接驳功能。

这被用于罚款。 然而,随着我开始在这里和那里(主要在其他活动中)增加一些手法和法典,在某个时候它停止了工作,现在我一直通过找到ById()号来找回一个名词。 我尝试重新启用R.java,重新命名“线” (以确保我控制出入地点;但只从这个地方进入)。 我试图将《刑法》纳入《经济、社会、文化权利国际公约》,但认为《刑法》可能太早,造成种族矛盾,但两者都没有关系。 我也确信,“线虫”确实被称为“温度控制器”,它(否则,产生的R.java将是错误的,会抱怨任何方面),而且任何地方都不会出现重复的“温度控制器”。

I m pretty much lost as to what the cause of this could be, so I d appreciate any suggestions or guesses.

这里是 st:

E/AndroidRuntime(  327): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(  327): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.PictureListView/com.company.PictureListView.PictureListView.PictureListActivity}: java.lang.NullPointerException
E/AndroidRuntime(  327):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
E/AndroidRuntime(  327):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime(  327):        at android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime(  327):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime(  327):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  327):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  327):        at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime(  327):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  327):        at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  327):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(  327):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(  327):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  327): Caused by: java.lang.NullPointerException
E/AndroidRuntime(  327):        at com.company.PictureListView.PictureListActivity.updateMainActivityScreen(PictureListActivity.java:50)
E/AndroidRuntime(  327):        at com.company.PictureListPictureListActivity.onCreate(PictureListActivity.java:38)
E/AndroidRuntime(  327):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(  327):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)

www.un.org/Depts/DGACM/index_french.htm 我当然要提到,我也提到了常设意见(R.layout.main),这样就不会出现问题。

<>PSS: 我反而试图在德国联邦调查局增加一个县,然后将载有该纽州呼吁书内发现的ById()的代码称作“德国调查组”,这起作用! 这使我回到这样的想法,即可能会出现一些种族对立。

最佳回答

这是对问题意见的答复:

Do you have an inner class in your activity? I read the exception trace carefully: first com.company.PictureListPictureListActivity.onCreate then com.company.PictureListView.PictureListActivity.updateMainActivityScreen --> seems to me findViewById is called in a different object. Try moving the findViewByID into the onCreate and check if it works there.

It seems there was an inner class at some point of development, which was later removed. Somehow project files were not updated appropriately. Cleaning the project, refreshing file system contents, and re-building the project should make things right again.

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签