Android程序的onCreate前挂起被称为(初级) [英] android program hangs before onCreate is called (beginner)

查看:259
本文介绍了Android程序的onCreate前挂起被称为(初级)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些样本code测试出 AudioRecord 类,我碰到这个网站的结果来了
链接到源$ C ​​$ C 结果
但是,程序不运行,并在一段时间后挂起。当程序启动时,它给了黑屏,不会做任何事情,并在一段时间后,一个消息框弹出说该程序没有响应,以及​​是否想将其关闭。结果
所以我加了 Toast.makeText(getApplicationContext(),这里,Toast.LENGTH_SHORT).show(); 的onCreate的第一行( ) MainActivity ,但即使这样敬酒不会在屏幕上显示出来。凡在哪里的程序可能会挂起可能的地点,甚至之前调用的onCreate()?我怎样才能找到这一行$​​ C $ C的?我测试了它在模拟器上。

I needed some sample code to test out the AudioRecord class and I came across this website
LINK TO THE SOURCE CODE
However the program doesn't run, and hangs after a while. When the program starts it gives blank screen and does not do anything, and after a while a message box pops up saying the program is not responding and whether I want to close it.
So I added Toast.makeText(getApplicationContext(), "HERE", Toast.LENGTH_SHORT).show(); as the first line of onCreate() in MainActivity, but even this toast does not show up on the screen. Where are possible locations where a program may hang, before even calling onCreate()? How can I locate that line of code? I tested it on the emulator.

推荐答案

不知道它的确切原因,但在XML布局文件它对引用@ + ID / textView1 但没有的TextView 在XML文件中定义的。
这可能指的是 TextView的了SDK默认创建以显示Hello World的标签,但是,从给定的例子已被删除。结果
其实看着在布局越多,行 Android上的code:layout_alignLeft =@ + ID / textView1是错误的,因为它有 @ + ID / 这意味着它正试图分配一个新的 ID / 的android:layout_alignLeft ,而不是使之成为价值@ ID / textView1匹配。
结果

Don't know if its the exact cause but in the XML layout file it makes references to @+id/textView1 but there is no TextView defined in the XML file. This may refer to the TextView that the SDK creates by default to show the "Hello World" label but has been removed from the example given.
In fact looking at the code in the layout more, the line android:layout_alignLeft="@+id/textView1" is wrong because it has @+id/ which means it is trying to assign a new id/ to android:layout_alignLeft instead of making it match the value "@id/textView1".

这篇关于Android程序的onCreate前挂起被称为(初级)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆