Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMPE419 Mobile Application Development

Similar presentations


Presentation on theme: "CMPE419 Mobile Application Development"— Presentation transcript:

1 CMPE419 Mobile Application Development
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department CMPE419 AU

2 Controling Buttons with a Single Listener
public class MainActivity extends ActionBarActivity implements View.OnClickListener { Button b1,b2,b3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); b1=(Button)findViewById(R.id.button1); b2=(Button)findViewById(R.id.button2); b3=(Button)findViewById(R.id.button3); b1.setOnClickListener(this); b2.setOnClickListener(this); b3.setOnClickListener(this); }

3 public void onClick(View v) { // TODO Auto-generated method stub
@Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()){ case R.id.button1: Toast.makeText(getApplicationContext(), "Button 1" , Toast.LENGTH_SHORT).show(); break; case R.id.button2: Toast.makeText(getApplicationContext(), "Button 2" , Toast.LENGTH_SHORT).show(); case R.id.button3: Toast.makeText(getApplicationContext(), "Button 3" , Toast.LENGTH_SHORT).show(); }


Download ppt "CMPE419 Mobile Application Development"

Similar presentations


Ads by Google