我试图运行我的代码,当我运行startTheGame onClick事件时,它会崩溃并显示以下日志。我试过在线查看,但我不知道我在日志文件中寻找什么错误。
03-13 14:22:57.810 1490-1490/com.example.sensational.timetopress W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
03-13 14:22:57.950 1490-1490/com.example.sensational.timetopress W/ResourceType﹕ No package identifier when getting value for resource number 0x0000001d
03-13 14:23:16.670 1569-1569/com.example.sensational.timetopress D/dalvikvm﹕ Late-enabling CheckJNI
03-13 14:23:16.738 1569-1575/com.example.sensational.timetopress D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
03-13 14:23:16.798 1569-1569/com.example.sensational.timetopress I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
03-13 14:23:16.798 1569-1569/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 11348: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
03-13 14:23:16.798 1569-1569/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
03-13 14:23:16.802 1569-1569/com.example.sensational.timetopress I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
03-13 14:23:16.802 1569-1569/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 11354: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
03-13 14:23:16.802 1569-1569/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
03-13 14:23:16.802 1569-1569/com.example.sensational.timetopress I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
03-13 14:23:16.802 1569-1569/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 9042: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
03-13 14:23:16.802 1569-1569/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
03-13 14:23:16.818 1569-1569/com.example.sensational.timetopress I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
03-13 14:23:16.822 1569-1569/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 365: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
03-13 14:23:16.822 1569-1569/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
03-13 14:23:16.822 1569-1569/com.example.sensational.timetopress I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
03-13 14:23:16.822 1569-1569/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 387: Landroid/content/res/TypedArray;.getType (I)I
03-13 14:23:16.822 1569-1569/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
03-13 14:23:16.870 1569-1569/com.example.sensational.timetopress D/dalvikvm﹕ GC_FOR_ALLOC freed 132K, 8% free 3685K/3980K, paused 10ms, total 10ms
03-13 14:23:17.018 1569-1569/com.example.sensational.timetopress I/dalvikvm-heap﹕ Grow heap (frag case) to 20.954MB for 18035652-byte allocation
03-13 14:23:17.030 1569-1578/com.example.sensational.timetopress D/dalvikvm﹕ GC_FOR_ALLOC freed 23K, 2% free 21274K/21596K, paused 11ms, total 11ms
03-13 14:23:17.038 1569-1573/com.example.sensational.timetopress D/dalvikvm﹕ GC_CONCURRENT freed <1K, 2% free 21274K/21596K, paused 1ms+0ms, total 9ms
03-13 14:23:17.454 1569-1569/com.example.sensational.timetopress D/libEGL﹕ loaded /system/lib/egl/libEGL_genymotion.so
03-13 14:23:17.454 1569-1569/com.example.sensational.timetopress D/﹕ HostConnection::get() New Host Connection established 0xb89737a8, tid 1569
03-13 14:23:17.466 1569-1569/com.example.sensational.timetopress D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_genymotion.so
03-13 14:23:17.466 1569-1569/com.example.sensational.timetopress D/libEGL﹕ loaded /system/lib/egl/libGLESv2_genymotion.so
03-13 14:23:17.542 1569-1569/com.example.sensational.timetopress W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
03-13 14:23:17.542 1569-1569/com.example.sensational.timetopress E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
03-13 14:23:17.542 1569-1569/com.example.sensational.timetopress E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 16384
03-13 14:23:17.550 1569-1569/com.example.sensational.timetopress E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
03-13 14:23:17.554 1569-1569/com.example.sensational.timetopress E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 16384
03-13 14:23:17.554 1569-1569/com.example.sensational.timetopress D/OpenGLRenderer﹕ Enabling debug mode 0
03-13 14:23:44.914 1569-1569/com.example.sensational.timetopress W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
03-13 14:23:44.914 1569-1569/com.example.sensational.timetopress W/ResourceType﹕ No package identifier when getting value for resource number 0x0000001d
03-13 14:23:44.914 1569-1569/com.example.sensational.timetopress D/AndroidRuntime﹕ Shutting down VM
03-13 14:23:44.914 1569-1569/com.example.sensational.timetopress W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d23b20)
03-13 14:23:44.914 1569-1569/com.example.sensational.timetopress E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.sensational.timetopress, PID: 1569
android.content.res.Resources$NotFoundException: String resource ID #0x1d
at android.content.res.Resources.getText(Resources.java:244)
at android.widget.TextView.setText(TextView.java:3888)
at com.example.sensational.timetopress.press_screen$1.onTick(press_screen.java:34)
at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:124)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
03-13 15:22:57.910 1824-1824/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 11348: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
03-13 15:22:57.910 1824-1824/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
03-13 15:22:57.910 1824-1824/com.example.sensational.timetopress I/dalvikvm﹕ Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
03-13 15:22:57.910 1824-1824/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 11354: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
03-13 15:22:57.910 1824-1824/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
03-13 15:22:57.910 1824-1824/com.example.sensational.timetopress I/dalvikvm﹕ Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
03-13 15:22:57.914 1824-1824/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 9042: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
03-13 15:22:57.914 1824-1824/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000e
03-13 15:22:57.914 1824-1824/com.example.sensational.timetopress I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
03-13 15:22:57.914 1824-1824/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 365: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
03-13 15:22:57.914 1824-1824/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
03-13 15:22:57.914 1824-1824/com.example.sensational.timetopress I/dalvikvm﹕ Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
03-13 15:22:57.914 1824-1824/com.example.sensational.timetopress W/dalvikvm﹕ VFY: unable to resolve virtual method 387: Landroid/content/res/TypedArray;.getType (I)I
03-13 15:22:57.914 1824-1824/com.example.sensational.timetopress D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0002
03-13 15:22:57.938 1824-1824/com.example.sensational.timetopress D/dalvikvm﹕ GC_FOR_ALLOC freed 138K, 8% free 3686K/3988K, paused 3ms, total 3ms
03-13 15:22:57.946 1824-1824/com.example.sensational.timetopress I/dalvikvm-heap﹕ Grow heap (frag case) to 20.955MB for 18035652-byte allocation
03-13 15:22:57.958 1824-1833/com.example.sensational.timetopress D/dalvikvm﹕ GC_FOR_ALLOC freed 23K, 2% free 21275K/21604K, paused 3ms, total 3ms
03-13 15:22:58.222 1824-1824/com.example.sensational.timetopress D/libEGL﹕ loaded /system/lib/egl/libEGL_genymotion.so
03-13 15:22:58.230 1824-1824/com.example.sensational.timetopress D/﹕ HostConnection::get() New Host Connection established 0xb8972b68, tid 1824
03-13 15:22:58.414 1824-1824/com.example.sensational.timetopress D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_genymotion.so
03-13 15:22:58.414 1824-1824/com.example.sensational.timetopress D/libEGL﹕ loaded /system/lib/egl/libGLESv2_genymotion.so
03-13 15:22:58.770 1824-1824/com.example.sensational.timetopress W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
03-13 15:22:58.770 1824-1824/com.example.sensational.timetopress E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
03-13 15:22:58.774 1824-1824/com.example.sensational.timetopress E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 16384
03-13 15:22:58.798 1824-1824/com.example.sensational.timetopress E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
03-13 15:22:58.798 1824-1824/com.example.sensational.timetopress E/OpenGLRenderer﹕ MAX_TEXTURE_SIZE: 16384
03-13 15:22:58.802 1824-1824/com.example.sensational.timetopress D/OpenGLRenderer﹕ Enabling debug mode 0
03-13 15:23:00.858 1824-1824/com.example.sensational.timetopress W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
03-13 15:23:00.858 1824-1824/com.example.sensational.timetopress W/ResourceType﹕ No package identifier when getting value for resource number 0x0000001d
03-13 15:23:00.858 1824-1824/com.example.sensational.timetopress D/AndroidRuntime﹕ Shutting down VM
03-13 15:23:00.858 1824-1824/com.example.sensational.timetopress W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d23b20)
03-13 15:23:00.858 1824-1824/com.example.sensational.timetopress E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.sensational.timetopress, PID: 1824
android.content.res.Resources$NotFoundException: String resource ID #0x1d
at android.content.res.Resources.getText(Resources.java:244)
at android.widget.TextView.setText(TextView.java:3888)
at com.example.sensational.timetopress.press_screen$1.onTick(press_screen.java:34)
at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:124)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Main_Screen
package com.example.sensational.timetopress;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
public class Main_Screen extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
}
public void startTheGame(View view){
Intent intent = new Intent(this, press_screen.class);
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main__screen, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Press_Screen
package com.example.sensational.timetopress;
import android.os.CountDownTimer;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
public class press_screen extends ActionBarActivity {
private int time_left;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_press_screen);
timer.start();
}
//Create Timer
CountDownTimer timer = new CountDownTimer(30000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
TextView amountOfTaps = (TextView) findViewById(R.id.amount_of_taps);
TextView timeLeftNumber = (TextView) findViewById(R.id.time_left_number_tv);
time_left = Integer.valueOf(timeLeftNumber.getText().toString()) - 1;
timeLeftNumber.setText(time_left);
}
@Override
public void onFinish() {
}
};
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_press_screen, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void triggerTapOnMainButton(View view) {
}
}
答案 0 :(得分:0)
只需更改
timeLeftNumber.setText(time_left);
到
timeLeftNumber.setText(time_left + "");
有关更多信息,setText
只接受resId作为整数参数,否则您需要先将其强制转换为String。