在我的设备上启动我自己的应用程序的黑屏

时间:2013-05-12 17:30:37

标签: android apk

我刚刚构建了我的第一个应用程序的apk。它可以在AVD模拟器中运行,但是当我在Desire HD上安装它时,一旦启动应用程序,屏幕就会变黑。 它是一个非常简单的应用程序,它只是在我在EditText中键入颜色并按下按钮时更改了blackground。 什么会导致黑屏问题?谢谢!

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final EditText colore = (EditText)this.findViewById(R.id.newcolor);
    Button conferma = (Button)this.findViewById(R.id.confirm);
    final RelativeLayout rl = (RelativeLayout)this.findViewById(R.id.lay);
    final TextView error = (TextView)this.findViewById(R.id.errore);

    OnClickListener l = new OnClickListener(){
        @Override
        public void onClick(View arg0){
            String s = colore.getText().toString();
            if (s.equals("Blu")){
                rl.setBackgroundColor(getResources().getColor(R.color.LightBlue));
                error.setText("");
            }else if(s.equals("Rosso")){
                rl.setBackgroundColor(getResources().getColor(R.color.IndianRed));
                error.setText("");
            }else if(s.equals("Verde")){
                rl.setBackgroundColor(getResources().getColor(R.color.LightGreen));
                error.setText("");
            }else if (s.equals("Bianco")){
                rl.setBackgroundColor(getResources().getColor(R.color.White));
                error.setText("");
            }else if (s.equals("Cacca")){
                rl.setBackground(getResources().getDrawable(R.drawable.cacca_rosa));
                error.setText("");
            }else{
                error.setText("Colore non disponibile, scegline uno dalla lista.");
            }
        }
    };
    conferma.setOnClickListener(l);
}

0 个答案:

没有答案
相关问题