Toast

 


public class MainActivity extends AppCompatActivity {
Button btnDefault, btnSimple, btnNested;

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


btnDefault = findViewById(R.id.btnDefault);
btnSimple = findViewById(R.id.btnSimple);
btnNested = findViewById(R.id.btnNested);

btnDefault.setOnClickListener(v -> Toast.makeText(MainActivity.this, "This is Default Toast", Toast.LENGTH_SHORT).show());

btnSimple.setOnClickListener(v -> {
Toast toast = Toast.makeText(MainActivity.this, "This is Simple Toast", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0,0);
toast.show();
});

btnNested.setOnClickListener(v -> {
Toast toast = Toast.makeText(MainActivity.this, "This is Nested Toast", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.BOTTOM | Gravity.END, 0,0);
toast.show();
});

}
}

একটি মন্তব্য পোস্ট করুন

0 মন্তব্যসমূহ