Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1 package com.example.second; 3 import android, support . v7.app.ActionBarActivi

ID: 3570980 • Letter: 1

Question

1 package com.example.second; 3 import android, support . v7.app.ActionBarActivity; 4 import android.app.Activity; 5 import android.os.Bundle; 6 import android.view.Menu; 7 import android.view.Menultem; 8 import android.view.View; 9 import android.widget.Button; 10 import android .widget. EditText; 11 import android.widget.TextView; 15 public class MainActivity extends ActionBarActivity { 16 private Button loginbutton; 17- @Override protected void onCreate(Bundle savedlnstanceState) { 19 super. onCreate(savedlnstanceState); 20 setContentView( R. layout. activity_main); ?21 loginbutton=(Button)findViewByld(R. id.buttonl); loginbutton.Q?li?jjsn(new 23 public void onClick(View arg){System.out.println(123);} )24 }); 25 } 26 27- @Override *28 public boolean onCreateOptionsMenu(Menu menu) { 29 II Inflate the menu; this adds items to the action bar if it is present. 30 getMenulnflaterO.inflate(R.menu.main, menu); 31 return true; 32 } 33 34 @Override 35 public boolean onOptionsltemSelected(Menultem item) { 36 // Handle action bar item clicks here. The action bar will 37 /1 automatically handle clicks on the Home/Up button, so long 38 II as you specify a parent activity in AndroidManifest.xml. 39 mt id = item.getltemldO; 40 if (id == R.id.action_settings) {

Explanation / Answer

You need to import android.view.View.OnClickListener;

class to use OnClickListner class in setOnClickListener method.