I’m new to android programming. How do you use android:onClick? Where do I put the method I want to call?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Button"
android:onClick="doSomething"/>
<ImageView
android:id="@+id/icon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="@drawable/molecule" />
Would I put it in the .java file that calls for this layout to be made?
Yes you need to put it in the activity class where you setContentView this layout.
The method for the onclick should be in the form of this: