在新屏幕中显示结果(android)
我有一个应用程序来计算屏幕混合。。按下按钮后,结果将显示在同一屏幕上。。我需要在新屏幕中单击按钮后显示结果 .爪哇 公共类维护活动6扩展活动{在新屏幕中显示结果(android),android,eclipse,Android,Eclipse,我有一个应用程序来计算屏幕混合。。按下按钮后,结果将显示在同一屏幕上。。我需要在新屏幕中单击按钮后显示结果 .爪哇 公共类维护活动6扩展活动{ double altura, largura, ratio, pixellarg, pixelalt, pixelportela, overlapperc, totallargpixel, totalpixelover, totalpixeloverfinal,numproj; @Override protected void onCreate(Bu
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;
}
}
double altura、largura、ratio、pixellarg、pixelalt、pixelportela、overlapperc、TotalArgPixel、totalpixelover、totalpixeloverfinal、numproj;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.tela_blend);
按钮btncalcblend=(按钮)findViewById(R.id.btncalcblend);
btncalcblude.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
//TODO自动生成的方法存根
EditText edtlargblend=(EditText)findViewById(R.id.edtlargblend);
EditText-EdtalBlend=(EditText)findViewById(R.id.EdtalBlend);
EditText EDTLAGPIxel=(EditText)findViewById(R.id.edTLAGPIxel);
EditText-edtaltpixel=(EditText)findViewById(R.id.edtaltpixel);
EditText-edtnumproj=(EditText)findViewById(R.id.edtnumproj);
如果(edtlargblend.getText().toString().length()设置活动和信息:
Intent i = new Intent(this, AActivityClass.class);
i.putExtra("Result1", result1);
i.putExtra("Result2", result2);
i.putExtra("Result3", result3);
startActivity(i);
从新活动中获取信息:
Intent intent = getIntent();
Int result1 = intent.getIntExtra("Result1", 0);
Int result2 = intent.getIntExtra("Result2", 0);
Int result3 = intent.getIntExtra("Result3", 0);
主动建议=>CreateMoreEasyReadVariables!您所说的“新屏幕”是什么意思?另一个活动或对话框屏幕?您可以拥有xml布局,并在当前活动内的对话框窗口中显示它们。startActivity(intent)像这样吗?但我需要显示3个不同的结果。你能给我一个例子吗?只需添加另一个带有另一个名称和结果的putExtra