【问题标题】:Program not running in emulator程序没有在模拟器中运行
【发布时间】:2012-05-20 21:56:44
【问题描述】:

我正在运行一个 android 应用程序,它只是弹出一个窗口说“你好”。当我在模拟器中运行它时,它显示“不幸的是,HelloAndroid 已停止。”我的代码有错误吗?

package com.example.helloandroid;

import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class HelloAndroid {

  public static void main(String[] args) {
    JFrame window = new JFrame();
    window.setVisible(true);
    window.setSize(200, 300);

    JLabel text = new JLabel();
    text.setText("Hello");
    text.setForeground(Color.RED);
    window.add(text);
  }

}

【问题讨论】:

  • 我不认为 Android 支持像那样使用 Swing...我建议关注 Android Hello World sample
  • @Greg 是正确的 - Android 确实支持完整的桌面 Java API,并且不支持 Swing 或 (IIRC) awt。
  • 谢谢,我明白了。

标签: android eclipse avd


【解决方案1】:

Android 不支持 Swing/(IIRC) awt 或完整的桌面 Java API。对不起。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-07
    • 2011-12-16
    • 2012-10-09
    • 1970-01-01
    • 1970-01-01
    • 2013-10-06
    • 1970-01-01
    相关资源
    最近更新 更多