随机运行时异常,不确定是什么原因造成的

发布于 2024-11-14 16:42:12 字数 1826 浏览 1 评论 0原文

我在设置活动内容视图的代码行中遇到运行时异常。这让我相信我的 xml 文件一定存在我根本没有看到的问题。任何帮助将不胜感激。

注意:第二个 TextView 设置为空白,因为与此视图关联的活动执行一些计算,其结果将显示在第二个 TextView 中。

<?xml version="1.0" encoding="utf-8"?>
<ReativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:background="@color/background" 
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >

  <TextView 
    android:id="@+id/results_label_textview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:text="@string/results_label" 
    android:layout_centerHorizontal="true" />

    <TextView
    android:id="@+id/results_textview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:text=" "
    android:layout_centerInParent="true" />

</ReativeLayout>

有什么想法吗?我想我这里编码有问题。

更新:这是堆栈

Thread [<1> main] (Suspended (exception RuntimeException))  
    ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663  
    ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679   
    ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125 
    ActivityThread$H.handleMessage(Message) line: 2033  
    ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
    Looper.loop() line: 123 
    ActivityThread.main(String[]) line: 4627    
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
    Method.invoke(Object, Object...) line: 521  
    ZygoteInit$MethodAndArgsCaller.run() line: 868  
    ZygoteInit.main(String[]) line: 626 
    NativeStart.main(String[]) line: not available [native method]  

I am getting a runtime exception on the line in my code that sets the content view for the activity. This leads me to believe that my xml file must have an issue that I am simply not seeing. Any help at all would be greatly appreciated.

NOTE: The second TextView is set to blank because the activity associated with this view performs some calculations of which the result will be displayed in the second TextView.

<?xml version="1.0" encoding="utf-8"?>
<ReativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:background="@color/background" 
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >

  <TextView 
    android:id="@+id/results_label_textview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:text="@string/results_label" 
    android:layout_centerHorizontal="true" />

    <TextView
    android:id="@+id/results_textview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:text=" "
    android:layout_centerInParent="true" />

</ReativeLayout>

Any ideas? I imagine I have something coded wrong here.

UPDATE: Here's the Stack

Thread [<1> main] (Suspended (exception RuntimeException))  
    ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663  
    ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679   
    ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125 
    ActivityThread$H.handleMessage(Message) line: 2033  
    ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
    Looper.loop() line: 123 
    ActivityThread.main(String[]) line: 4627    
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
    Method.invoke(Object, Object...) line: 521  
    ZygoteInit$MethodAndArgsCaller.run() line: 868  
    ZygoteInit.main(String[]) line: 626 
    NativeStart.main(String[]) line: not available [native method]  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

归属感 2024-11-21 16:42:12

我想你现在已经解决了这个问题,但我在 setContentView 上也遇到了类似的问题。在浪费了几个小时检查语法和拼写以及上网冲浪之后,我所要做的就是清理项目,它运行得很好。

I imagine you've solved this by now, but I had a similar problem with setContentView. After wasting hours checking syntax and spelling and surfing the web, all I had to do was clean the project and it worked perfectly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文