我在运行应用程序时不断收到错误消息?
错误日志中没有任何内容,它并没有真正告诉我错误来自哪里,但我在 LogCat 中得到了这个:
WARN/ActivityManager(51): Launch timeout has expired, giving up wake lock!
WARN/ActivityManager(51): Activity idle timeout for HistoryRecord{44e0fb68 com.gamer.network2/.FirstActivity}
WARN/InputManagerService(51): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44e98158
ERROR/gralloc(51): [unregister] handle 0x494d08 still locked (state=40000001)
这是我的 Java,用于应用程序启动时出现的布局:(我想如果这这是首先出现的,这就是问题所在,但我真的不知道。)
package com.gamer.network2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class FirstActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView next1 = (TextView) findViewById(R.id.signuptext);
next1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Screen2.class);
startActivityForResult(myIntent, 0);
finish();
}
});
}
}
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gamer.network2"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="@drawable/newlogo2"
android:label="@string/app_name">
<activity android:name=".FirstActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Screen2"></activity>
<activity android:name=".Screen3"></activity>
<activity android:name=".Screen4"></activity>
<activity android:name=".MyOnItemSelectedListener"></activity>
</application>
</manifest>
以及布局/主要的 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:weightSum="1"
>
<ImageView android:src="@drawable/newlogo2"
android:id="@+id/imageView1"
android:layout_gravity="center"
android:layout_marginTop="30dip"
android:layout_height="112dp"
android:layout_weight="0.11"
android:layout_width="135dp"></ImageView>
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/textView2"
android:text="Sign in to GameNet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dip"></TextView>
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/textView3"
android:text="Username:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dip"
android:layout_marginTop="15dip"></TextView>
<EditText android:id="@+id/EnterUsername"
android:layout_height="wrap_content"
android:layout_width="190dp"
android:layout_gravity="center">
<requestFocus></requestFocus>
</EditText>
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/textView4"
android:text="Password: "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dip"
android:layout_marginTop="10dip"></TextView>
<EditText
android:id="@+id/EnterPassword"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:layout_gravity="center"
android:layout_width="190dp"></EditText>
<Button android:text="Sign in"
android:id="@+id/button1"
android:layout_width="121dp"
android:layout_gravity="center"
android:layout_height="wrap_content"></Button>
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/signuptext"
android:text="Not a member? Sign up now!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dip"></TextView>
</LinearLayout>
我可以发布您需要帮助我的任何其他代码。 =]
谢谢
This is the error message I keep getting when I run my app in the emulator.
There's nothing in the Error Log and it doesn't really tell me where the error is coming from but I get this in the LogCat:
WARN/ActivityManager(51): Launch timeout has expired, giving up wake lock!
WARN/ActivityManager(51): Activity idle timeout for HistoryRecord{44e0fb68 com.gamer.network2/.FirstActivity}
WARN/InputManagerService(51): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44e98158
ERROR/gralloc(51): [unregister] handle 0x494d08 still locked (state=40000001)
This is my Java for the Layout that comes up when the app is started: (I would think if this is what comes up first, that would be where the problem is, but I really don't know.)
package com.gamer.network2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class FirstActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView next1 = (TextView) findViewById(R.id.signuptext);
next1.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Screen2.class);
startActivityForResult(myIntent, 0);
finish();
}
});
}
}
Here's my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gamer.network2"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<application android:icon="@drawable/newlogo2"
android:label="@string/app_name">
<activity android:name=".FirstActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Screen2"></activity>
<activity android:name=".Screen3"></activity>
<activity android:name=".Screen4"></activity>
<activity android:name=".MyOnItemSelectedListener"></activity>
</application>
</manifest>
And the XML code for the layout/main:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:weightSum="1"
>
<ImageView android:src="@drawable/newlogo2"
android:id="@+id/imageView1"
android:layout_gravity="center"
android:layout_marginTop="30dip"
android:layout_height="112dp"
android:layout_weight="0.11"
android:layout_width="135dp"></ImageView>
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/textView2"
android:text="Sign in to GameNet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dip"></TextView>
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/textView3"
android:text="Username:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dip"
android:layout_marginTop="15dip"></TextView>
<EditText android:id="@+id/EnterUsername"
android:layout_height="wrap_content"
android:layout_width="190dp"
android:layout_gravity="center">
<requestFocus></requestFocus>
</EditText>
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/textView4"
android:text="Password: "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="70dip"
android:layout_marginTop="10dip"></TextView>
<EditText
android:id="@+id/EnterPassword"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:layout_gravity="center"
android:layout_width="190dp"></EditText>
<Button android:text="Sign in"
android:id="@+id/button1"
android:layout_width="121dp"
android:layout_gravity="center"
android:layout_height="wrap_content"></Button>
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/signuptext"
android:text="Not a member? Sign up now!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dip"></TextView>
</LinearLayout>
I can post whatever other code you need to help me. =]
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 onClickListener 仅适用于按钮,不适用于文本视图
i think onClickListener is for buttons only, not textviews