package com.example.android.miwok; import android.conent.Intent; import android.support.v7.app.AppCompactActivity; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompactActivity { @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Find the View that shows the numbers category TextView numbers = (TextView)findViewById(R.id.numbers); //Set a clickListener on that View numbers.setOnClickListener(new OnClickListener(){ @Override public void onClick(View view){ Intent numbersIntent = new Intent(MainActivity.this, NumbersActivity.class); startActivity(numbersIntent); } }); } }
Button button = (Button) findViewById(R.id.ze_button); button.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(view v){ doSomeStuff(); } });
android:onClick="myListener" public void myListener(View view){ doSomeStuff(); }