Add onclick method on main java file and xml file.
res > layout > activity_main.xml
<?xml version="1.0" encoding="utf-8" ?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://chemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/tan_background" android:orientation="vertical" tools:context="com.example.android.miwok.MainActivity"> <TextView android:id="@+id/numbers" style="@style/CategoryStyle" android:background="@color/category_numbers" android:text="Numbers" android:onClick="openNumberList" /> <TextView android:id="@+id/family" style="@style/CategoryStyle" android:background="@color/category_family" android:text="Family Members" /> <TextView android:id="@+id/colors" style="@style/CategoryStyle" android:background="@color/category_colors" android:text="Calors" /> <TextView android:id="@+id/phrases" style="@style/CategoryStyle" android:background="@color/category_phrases" android:text="Phrases" /> </LinearLayout>
MainActivity.java
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); } public void openNumbersList(View view){ //TODO: Write your code here! Intent i = new Intent(this, NumbersActivity.class); startActivity(i); } }
android intent tutorial site
http://www.vogella.com/tutorials/AndroidIntent/article.html#usingintents_call