我對這個有錯誤,,可惜停止機器人,我得到了錯誤不幸的是停止
package com.example.myapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MyActivity extends Activity {
/**
* Called when the activity is first created.
*/
public int myNum = 0;
public TextView counterNum = (TextView) findViewById(R.id.counterNum);
public Button counterBtn = (Button) findViewById(R.id.counterBtn);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
counterBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
counterNum.setText(String.valueOf(++myNum));
}
});
}
}
請幫我告訴我爲什麼我得到停止。
這裏main.xml中
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="0"
android:id="@+id/counterNum"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="68dp"
android:textColor="#ffffffff"
android:textSize="100dp"
android:textIsSelectable="false"
android:numeric="integer"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:id="@+id/counterBtn"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="147dp"
android:textSize="45dp"
android:textColor="#ff0a000a"
android:width="100dp"
android:height="100dp"/>
我logcat的
12月12日至3日:19:37.718一〇六三年至1063年/ COM。 example.myapp E/Trace:錯誤 打開跟蹤文件:No such文件或目錄(2) 12-03 12:19:38.348 1063-1063/com.example.myapp D/libEGL:loaded /system/lib/egl/libEGL_emulation.so 12-03 12:19:38.359 1063- 1063/com.example.myapp D /:HostConnection :: get()建立新的主機連接0x2a0dbe58,tid 12-03 12:19:38.399 1063-1063/com.example.myapp D/libEGL:loaded/system /lib/egl/libGLESv1_CM_emulation.so 12-03 12:19:38.409 1063-1063/com.example.myapp D/libEGL:loaded /system/lib/egl/libGLESv2_emulation.so 12-03 12:19:38.588 1063-1063/com.example.myapp W/EGL_emulation:eglSurfaceAttrib未實現 12-03 12:19:38.609 1063-1063/com.example.myapp D/OpenGLRenderer:啓用調試模式0
我正在使用IntellIJ Idea
它得到了「停止」,因爲有錯誤,發佈錯誤 – tyczj 2014-12-01 15:49:47
添加您的堆棧跟蹤 – 2014-12-01 15:51:01
哪裏是你的logcat的? – Machado 2014-12-01 15:55:37