0

嗨,我启动了一个应用程序并想对其进行测试,所以我使用了 avd,当应用程序启动时它崩溃了,我希望有人能提供帮助

这是我的java类

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MemoryInfo mi = new MemoryInfo();
    ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(mi);
    long availableMegs = mi.availMem / 1048576L;

    TextView manufacturerTextView = (TextView)findViewById(R.id.mem);
    manufacturerTextView.setText((int) mi.availMem);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

}

LOGCAT

02-06 07:10:05.202: E/AndroidRuntime(771): 致命异常: main 02-06 07:10:05.202: E/AndroidRuntime(771): java.lang.RuntimeException: 无法启动活动 ComponentInfo{com. example.test/com.example.test.MainActivity}:android.content.res.Resources$NotFoundException:字符串资源 ID #0x18184000 02-06 07:10:05.202:E/AndroidRuntime(771):在 android.app.ActivityThread .performLaunchActivity(ActivityThread.java:2180) 02-06 07:10:05.202: E/AndroidRuntime(771): 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 02-06 07:10:05.202: E /AndroidRuntime(771): 在 android.app.ActivityThread.access$600(ActivityThread.java:141) 02-06 07:10:05.202: E/AndroidRuntime(771): 在 android.app.ActivityThread$H.handleMessage(ActivityThread .java:1234)

4

2 回答 2

3

采用

manufacturerTextView.setText(String.valueOf((int) mi.availMem));

反而

manufacturerTextView.setText((int) mi.availMem);

用于在 TextView 中显示整数值

于 2013-02-06T06:58:28.197 回答
0

将其转换为字符串以显示

于 2013-02-06T07:00:11.550 回答