我有一个计算屏幕混合的应用程序。当按下按钮时,结果显示在同一个屏幕上。。我需要在新屏幕中单击按钮后显示结果...
.java
公共类 MainActivity6 扩展 Activity {
double altura, largura, ratio, pixellarg, pixelalt, pixelportela, overlapperc, totallargpixel, totalpixelover, totalpixeloverfinal,numproj;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tela_blend);
Button btncalcblend = (Button) findViewById(R.id.btncalcblend);
btncalcblend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
EditText edtlargblend = (EditText) findViewById(R.id.edtlargblend);
EditText edtaltblend = (EditText) findViewById(R.id.edtaltblend);
EditText edtlargpixel = (EditText) findViewById(R.id.edtlargpixel);
EditText edtaltpixel = (EditText) findViewById(R.id.edtaltpixel);
EditText edtnumproj = (EditText) findViewById(R.id.edtnumproj);
if (edtlargblend.getText().toString().length() <= 0){
edtlargblend.setError("Digite a largura");
edtlargblend.requestFocus();
}else if (edtaltblend.getText().toString().length() <= 0){
edtaltblend.setError("Digite a altura");
edtaltblend.requestFocus();
}else if (edtlargpixel.getText().toString().length() <= 0){
edtlargpixel.setError("Digite largura pixel");
edtlargpixel.requestFocus();
}else if (edtaltpixel.getText().toString().length() <= 0){
edtaltpixel.setError("Digite altura pixel");
edtaltpixel.requestFocus();
}else if (edtnumproj.getText().toString().length() <= 0){
edtnumproj.setError("Digite número projetores");
edtnumproj.requestFocus();
}else {
largura = Double.parseDouble(edtlargblend.getText().toString());
altura = Double.parseDouble(edtaltblend.getText().toString());
pixellarg = Double.parseDouble(edtlargpixel.getText().toString());
pixelalt = Double.parseDouble(edtaltpixel.getText().toString());
numproj = Double.parseDouble(edtnumproj.getText().toString());
ratio = largura / altura;
totallargpixel = ratio * pixelalt;
totalpixelover = pixellarg * numproj;
totalpixeloverfinal = totalpixelover -totallargpixel;
pixelportela = totalpixeloverfinal / (numproj - 1);
overlapperc = (pixelportela /pixellarg) * 100;
EditText edttotalpixel = (EditText) findViewById(R.id.edttotalpixel);
edttotalpixel.setText(String.valueOf(totalpixeloverfinal));
EditText edtpixelportela = (EditText) findViewById(R.id.edtpixelportela);
edtpixelportela.setText(String.valueOf(pixelportela));
EditText edtoverlaperc = (EditText) findViewById(R.id.edtoverlaperc);
edtoverlaperc.setText(String.valueOf(overlapperc));
edtoverlaperc.setText(String.format("%.2f", overlapperc));
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edtnumproj.getWindowToken(),0);
}
}
});
Button btnvolt = (Button) findViewById(R.id.btnvoltar);
btnvolt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent dtec = new
Intent(MainActivity6.this, MainActivity.class);
MainActivity6.this.startActivity(dtec);
MainActivity6.this.finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}