I want to be able to open 3 buttons within the same java class in Android studio , a map , button leading to text and pictures and the last one a video .. i used the following codes :
public void location(View view) {
Button great = (Button) findViewById(R.id.location);
great.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// TODO Auto-generated method stub
Intent intent = new Intent(getApplicationContext(),location`enter code here`.class);
startActivity(intent);
}
});
}
the same for the other 2 buttons . as for the .xml file
<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="@string/history"
android:id="@+id/button"
android:onClick="location"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"/>
and the string is
<string name="map">Map</string>
<string name="location">Location</string>
<string name="info">information about related subject
</string>
the thing is how can i open all 3 buttons in the same main layout ? do i use
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(),location`enter code here`.class);
}
in all 3 buttons ? or do i have to assign each button to a different java class ? specially when all API setting (import google map ) shows up grey in the main java ?