- Java/Android, Multiple Classes
- package com.abc.example;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuInflater;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- public class FindUs extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
- setContentView(R.layout.findUs);
- Button first = (Button) findViewById(R.id.first);
- Button second = (Button) findViewById(R.id.second);
- Button third = (Button) findViewById(R.id.third);
- Button fourth = (Button) findViewById(R.id.fourth);
- first.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- startActivity(new Intent("com.abc.example.FIRST"));
- }
- });
- second.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- startActivity(new Intent("ccom.abc.example.SECOND"));
- }
- });
- third.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- startActivity(new Intent("com.abc.example.THIRD"));
- }
- });
- fourth.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- startActivity(new Intent("com.abc.example.FOURTH"));
- }
- });
- }
- package com.abc.example;
- import android.app.Activity;
- import android.content.Intent;
- import android.net.Uri;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuInflater;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- public class First extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
- setContentView(R.layout.first);
- Button callFirst= (Button) findViewById(R.id.callfirst);
- Button mapFirst= (Button) findViewById(R.id.mapfirst);
- callFirst.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- String phoneNumber = "tel:+18000000000";
- Intent callIntent = new Intent(Intent.ACTION_CALL);
- callIntent.setData(Uri.parse(phoneNumber));
- startActivity(callIntent);
- }
- });
- mapFirst.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- // TODO Auto-generated method stub
- String url = "grab google directions for this place";
- Intent mapIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
- startActivity(mapIntent);
- }
- });
- }