NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

--------------TOAST ÖRNEK ---------------------------
--------------MAIN ACTİVİTY---------------------------
public void basitToast(View view) { //R.DRAWABLE A RESİMLERİ KOY

Toast.makeText(this,"Basit toasta basıldı.",Toast.LENGTH_SHORT).show(); //basit toast yapımı btnonclick

}

public void resimliToast(View view) { //RESİMLİ TOAST GÖSTERME //BUTTTON RESİMLITOAST ONCLICKINE YAZILDI
ImageView kedi = new ImageView(MainActivity.this);
kedi.setImageResource(R.drawable.kedi); //dosya yolunu belirtmiş
Toast toast = new Toast (getApplicationContext()); //bu applicationda geçerli
toast.setView(kedi); //kediyi toast mesaja koy
toast.setDuration(Toast.LENGTH_LONG);
toast.show();

}

public void yaziliToast(View view) { //BELİRLENEN YAZI ŞEKLİNE GÖRE TOAST GÖSTERME

TextView yazi = new TextView(getApplicationContext());
yazi.setTextSize(25);
yazi.setTextColor(Color.RED);
yazi.setText("Süslü Yazı");
Toast toast = new Toast(getApplicationContext());
toast.setView(yazi);
toast.setDuration(Toast.LENGTH_LONG);
toast.show();


}

--------------RADİOBUTTON ÖRNEK ---------------------------
--------------MAIN ACTİVİTY---------------------------


RadioGroup rbGroup ;
RadioButton rbKirmizi;
RadioButton rbSari,rbSiyah;
ConstraintLayout ekran;


@Override
protected void onCreate(Bundle savedInstanceState) { //RADİOBUTTONLAR RADİOBUTTONUN İÇERİSİNDE OLMASI LAZIM
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ekran = findViewById(R.id.ekran);
rbGroup = findViewById(R.id.RbGroup);
rbKirmizi = findViewById(R.id.rbKirmizi);
rbSari = findViewById(R.id.rbSari);
rbSiyah = findViewById(R.id.rbSiyah);

rbGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { //RADİOBUTTONUN HANGİSİ TIKLANMA NESNESİ
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (rbKirmizi.isChecked()) //İSCHECKED TIKLANDI İSE
{
ekran.setBackgroundColor(Color.RED);
}
if (rbSari.isChecked())
{
ekran.setBackgroundColor(Color.YELLOW);
}
if (rbSiyah.isChecked())
{
ekran.setBackgroundColor(Color.BLACK);
}


}
});


}
--------------RESİM TIKLAYARAK DEGİŞTİRME ÖRNEK ---------------------------
--------------MAIN ACTİVİTY---------------------------



ImageView resim1;
int sayac = 0 ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
resim1 = findViewById(R.id.imgView);
resim1.setOnClickListener(new View.OnClickListener() { //IMAGEVİEW E TIKLANDIGINDA CALISACAK KOD
@Override
public void onClick(View v) {

if (sayac % 2 == 0) //
{
resim1.setImageResource(R.drawable.tir2); //IMAGEVİEW E RESİM ATAMA
sayac++;
}
else
{
resim1.setImageResource(R.drawable.tir1);
sayac++;
}

}
});

}

--------------SPİNNERLI HESAP MAKİNASI ÖRNEK ---------------------------
--------------MAIN ACTİVİTY---------------------------

public class MainActivity extends AppCompatActivity {


EditText et1,et2;
TextView tvSonuc;
List<String> list;
Spinner spinner;
ArrayAdapter<String> adapter;

double s1,s2;

double sonuc ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinner = findViewById(R.id.spinner);
et1 = findViewById(R.id.et1);
et2= findViewById(R.id.et2);
tvSonuc=findViewById(R.id.tvSonuc);

list = new ArrayList<>();
list.add("Bir işlem Seç");
list.add("Toplama");
list.add("Cikarma");
list.add("Carpma");
list.add("Bolme");

adapter = new ArrayAdapter<>(this,android.R.layout.simple_spinner_dropdown_item,list);// adapter ı listeye aktarma
spinner.setAdapter(adapter); //adapter a spinner a aktarma

spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { // spinner seçili işlemi position ile bulma
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position != 0){ //program ilk açıldığında bir işlem seç seçili değilse çalışsın.

s1 = Double.parseDouble(et1.getText().toString());
s2 = Double.parseDouble(et2.getText().toString());

if (position == 1)
{
sonuc = s1+s2;

}
if (position == 2)
{
sonuc = s1-s2;

}

}


}
@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});


}

public void btnHesap(View view) {

tvSonuc.setText(sonuc+"");

}

}


--------------INTENT SAYFA GEÇİŞ VİZE FİNAL ÖRNEK ---------------------------
--------------MAIN ACTİVİTY---------------------------

ad = findViewById(R.id.etad);
s1=findViewById(R.id.ets1);
s2=findViewById(R.id.ets2);
btn = findViewById(R.id.btnHesap);


btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
byte vize = Byte.parseByte(s1.getText().toString());
byte fnl = Byte.parseByte(s2.getText().toString());
String isim = ad.getText().toString();

int bn = (vize+fnl)/2;

Intent i = new Intent(MainActivity.this,sonucActivity.class);
i.putExtra("isim",isim);
i.putExtra("basari",bn);
startActivity(i);

}
});


--------------SONUC ACTİVİTY ÖRNEK ---------------------------
--------------MAIN ACTİVİTY---------------------------


tvAd = findViewById(R.id.textView);
tvSonuc = findViewById(R.id.textView2);
String ad = getIntent().getExtras().getString("isim","");
tvAd.setText(ad);
int bn = getIntent().getExtras().getInt("basari",0);
tvSonuc.setText(String.valueOf(bn));
----------------------------------------------------------------


--------------SPİNNER İLE SEÇİLDİGİ AN HESAPLATIP GEÇİŞ ---------------------------
--------------MAIN ACTİVİTY---------------------------
EditText et1, et2;
Spinner spinner;
String islemler[] = new String[]{"İşlemi Seçiniz", "toplama", "cıkarma"}; //SPİNNER İÇİN DİZİ
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


et1 = findViewById(R.id.etS1);
et2 = findViewById(R.id.etS2);
spinner = findViewById(R.id.sp);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, islemler); //DİZİYİ ARRAY ADAPTERE AKTARMA

spinner.setAdapter(arrayAdapter);

spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

int s1 = Integer.parseInt( et1.getText().toString());
int s2 = Integer.parseInt( et2.getText().toString());
int sonuc ;
Intent intent = new Intent(MainActivity.this,sonucActivity.class);

if(position == 1)
{
sonuc = s1+s2;
intent.putExtra("sonuc",sonuc);
startActivity(intent);
}

if(position == 2)
{
sonuc = s1-s2;
intent.putExtra("sonuc",sonuc);
startActivity(intent);
}
}


@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});

}
}
--------------SPİNNER İLE SEÇİLDİGİ AN HESAPLATIP GEÇİŞ ---------------------------
--------------SONUC ACTİVİTY---------------------------
setContentView(R.layout.activity_sonuc);
tvSonuc = findViewById(R.id.tvSonuc);

int bn = getIntent().getExtras().getInt("sonuc",(int) 0);
tvSonuc.setText(bn+"");



--------------BASİT HESAP MAKİNESİ ---------------------------
--------------SONUC ACTİVİTY---------------------------

Button btnTopla,btnCikar,BtnCarp,btnBol;
EditText ets1,ets2;
TextView tvSonuc;
double s1 ;
double s2 ;
double sonuc;

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

btnTopla = findViewById(R.id.btntopla);
btnCikar = findViewById(R.id.btncıkar);
BtnCarp = findViewById(R.id.btncarp);
btnBol= findViewById(R.id.btnBol);
ets1 = findViewById(R.id.et1);
ets2 = findViewById(R.id.et2);
tvSonuc = findViewById(R.id.tvSonuc);
}

public void topla(View view) {
s1= Double.parseDouble(ets1.getText().toString());
s2= Double.parseDouble(ets2.getText().toString());
sonuc = s1+s2;
tvSonuc.setText(s1+" - "+s2 +" = "+sonuc);;
}

public void cikar(View view) {
s1= Double.parseDouble(ets1.getText().toString());
s2= Double.parseDouble(ets2.getText().toString());
sonuc = s1-s2;
tvSonuc.setText(s1+" + "+s2 +" = "+sonuc);
}
public void carp(View view) {

s1= Double.parseDouble(ets1.getText().toString());
s2= Double.parseDouble(ets2.getText().toString());
sonuc = s1*s2;
tvSonuc.setText(s1+" * "+s2 +" = "+sonuc);
}

public void bol(View view) {

s1= Double.parseDouble(ets1.getText().toString());
s2= Double.parseDouble(ets2.getText().toString());
sonuc = s1/s2;
tvSonuc.setText(s1+" / "+s2 +" = "+sonuc);
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.