I am guessing you have this
public void getLocation(View v) {
in Fragment
You need to have this
public void getLocation(View v)
in Activity
.
public static final int onClick
Added in API level 4 Name of the method in this View's context to invoke when the view is clicked. This name must correspond to a public method that takes exactly one parameter of type View. For instance, if you specify android:onClick="sayHello", you must declare a public void sayHello(View v) method of your context (typically, your Activity).
Or in Fragments onCreateView
Initialize button as below and set click listener and get rid of android:onClick:getLocation
Button button =(Button)rootView.findViewById(R.id.get_location_button);
button.setOnClickListener( new OnClickListener()
{
@Override
public void onClick(View v)
{
// do something
}
});
If you need Context
use getActivity()
.