首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Android应用程序在模拟器和Nexus 10中不断崩溃。

Android应用程序在模拟器和Nexus 10中不断崩溃。
EN

Stack Overflow用户
提问于 2014-02-01 15:22:04
回答 1查看 471关注 0票数 2

这个应用程序在模拟器中不断崩溃(我已经为它分配了700 MB内存,是一个Nexus 4),当我尝试将它加载到我的Nexus 10和Galaxy上时。我认为这是因为Java中关于如何切换Android活动的几个错误,我对此发出警告,而不是错误。这是代码:

代码语言:javascript
运行
复制
    package com.example.ldsm2;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;

public class Instructions extends Activity {

/** Called when the user clicks the Send button */
public void Ldsm (View view) {
    Object Intent = startActivity(Ldsm.class);  
}

private com.example.ldsm2.intent startActivity(
        Class<Ldsm> class1) {
    // TODO Auto-generated method stub
    return null;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_instructions);
}

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

}

因为其他活动只有不同的活动可切换,所以我只需将代码复制到其他活动的Java源代码文件中,但将活动更改为切换到(学生将单击一个按钮并将其发送到另一个问题以解决)。

然而,这似乎并不是应用程序中唯一的问题。该应用程序本应显示图像,但对于该功能还有另一个警告。这是XML代码,再次复制到其他活动文件,因为它们只需要显示另一个图像。

代码语言:javascript
运行
复制
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Ldsm" >

<EditText
    android:id="@+id/launch_codes"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/enter_launch_codes"
    android:imeActionLabel="@string/launch"
    android:inputType="number" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:onClick="methodName"
    android:text="@string/instructions" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/launch_codes"
    android:layout_alignParentRight="true"
    android:onClick="modeon"
    android:text="@string/button_send" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_below="@+id/launch_codes"
    android:layout_marginTop="141dp"
    android:layout_toLeftOf="@+id/button2"
    android:src="@drawable/ic_pro1" android:contentDescription="TODO"/>

这些是Eclipse problems选项卡中出现的警告。对于XML代码,出现的错误是:“描述:局部变量意图的值没有使用第16行Java问题,对于Java代码:描述资源路径定位类型可访问性类型缺少图像行37 Android问题上的contentDescription属性。

最后,这是当我尝试在模拟器中启动应用程序时出现的错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-01 17:37:40

您需要使用LogCat来查看它的内容。对于正在发生的事情,将会有一些线索。

代码语言:javascript
运行
复制
[Accessibility] Missing contentDescription attribute  

是为视障人士准备的。此值由屏幕阅读器读出。从根本上讲,它的意思是有可能出现可访问性错误。

代码语言:javascript
运行
复制
The value of the local variable Intent is not used  

这告诉您,尽管您已经为变量分配了一个值,但是您从未在代码中的任何地方使用过它。除非您计划使用它,否则您可以安全地删除它。因为它是Intent,所以我想您正在计划启动其他的Activity

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21499862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档