我正在编写代码来编写 TextView,但是当我单击应用程序时出现错误:
不幸的是 aulanewboston1 已经停止。
我在AndroidManifest.xml
这是控制台中显示的代码和错误
package com.br.aulanewboston1.boston;
import java.util.Random;
import android.R.string;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.InputType;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;
public class TextTela extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text);
Button chkCmd = (Button) findViewById(R.id.bResult);
final ToggleButton passTog = (ToggleButton) findViewById(R.id.tbpassword);
final EditText senha = (EditText) findViewById(R.id.edtextsenha);
final TextView display =(TextView) findViewById(R.id.tvDisplay);
passTog.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if(passTog.isChecked()){
senha.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}else{
senha.setInputType(InputType.TYPE_CLASS_TEXT);
}
}
});
chkCmd.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String check = senha.getText().toString();
display.setText(check);
if(check.contentEquals("left")){
display.setGravity(Gravity.LEFT);
}else if(check.contentEquals("center")){
display.setGravity(Gravity.CENTER);
}else if (check.contentEquals("right")){
display.setGravity(Gravity.RIGHT);
}else if (check.contentEquals("blue")){
display.setTextColor(Color.BLUE);
}else if (check.contains("WTF")){
Random crazy = new Random();
display.setText("WFT");
display.setTextSize(crazy.nextInt(75));
display.setTextColor(Color.rgb( crazy.nextInt(265), crazy.nextInt(265), crazy.nextInt(265)));
switch(crazy.nextInt(3)){
case 0:
display.setGravity(Gravity.LEFT);
break;
case 1:
display.setGravity(Gravity.CENTER);
break;
case 2:
display.setGravity(Gravity.RIGHT);
break;
}
}else {
display.setText("invalido");
display.setGravity(Gravity.CENTER);
display.setTextColor(Color.WHITE);
}
}
});
}
}
错误信息
[2012-06-29 20:09:39 - NewBoston] ActivityManager: Starting: Intent {
act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
cmp=com.br.aulanewboston1.boston/.Tema }
[2012-06-29 20:09:39 - NewBoston] ActivityManager: Warning: Activity not started,
its current task has been brought to the front