şimdi kodları yazmaya başlıcaz.Src içerisindeki java dosyamızı açıyoruz.
şimdi çıkan pencereye aşağıdaki kodları yazıcaz.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText sayı1=(EditText)findViewById(R.id.sayı1);
final EditText sayı2=(EditText)findViewById(R.id.sayı1);
final TextView sonuc=(TextView)findViewById(R.id.sonuc);
Button topla=(Button)findViewById(R.id.topla);
topla.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
float sayı1float=Float.parseFloat(sayı1.getText().toString());
float sayı2float=Float.parseFloat(sayı2.getText().toString());
sonuc.setText(String.valueOf(sayı1float+sayı2float));
}
});
}
@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;
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText sayı1=(EditText)findViewById(R.id.sayı1);
final EditText sayı2=(EditText)findViewById(R.id.sayı1);
final TextView sonuc=(TextView)findViewById(R.id.sonuc);
Button topla=(Button)findViewById(R.id.topla);
topla.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
float sayı1float=Float.parseFloat(sayı1.getText().toString());
float sayı2float=Float.parseFloat(sayı2.getText().toString());
sonuc.setText(String.valueOf(sayı1float+sayı2float));
}
});
}
@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;
}
}



Hiç yorum yok:
Yorum Gönder