Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6697525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:28:11+00:00 2026-05-26T06:28:11+00:00

I separated my app in 3 classes. the main class where the user can

  • 0

I separated my app in 3 classes. the main class where the user can choose which feature to use. The map feature works fine but my directions features doesn’t when the user clicks on the button is causes a force close, I think it has something to do with the layout.

Main Class file

package com.sammy.umass;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.content.Intent;
import android.widget.Button;



public class UMassGuide extends Activity {
/** Called when the activity is first created. */



//buttons
private Button goHereButton;
private Button mapButton;
private Button spireButton;
private Button sparkButton;
private Button websiteButton;

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    goHereButton  = (Button) findViewById(R.id.button1);
    goHereButton.setOnClickListener(new View.OnClickListener() 
    {
       public void onClick(View arg0) 
       {
       Intent i = new Intent(UMassGuide.this, DirectionsScreenActivity.class);
       startActivity(i);
       }
    });

    mapButton  = (Button) findViewById(R.id.button2);
    mapButton.setOnClickListener(new View.OnClickListener() 
    {
       public void onClick(View arg0) 
       {
       Intent i = new Intent(UMassGuide.this, UmassMap.class);
       startActivity(i);
       }
    });

    spireButton  = (Button) findViewById(R.id.button3);
    spireButton.setOnClickListener(new View.OnClickListener() 
    {
        public void onClick(View arg0) 
        {
            Uri uri = Uri.parse("https://spire.umass.edu/psp/heproda/EMPLOYEE/HRMS/?cmd=login&languageCd=ENG&"); 
            Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);
        }
     });

    sparkButton  = (Button) findViewById(R.id.button4);
    sparkButton.setOnClickListener(new View.OnClickListener() 
    {
        public void onClick(View arg0) 
        {
            Uri uri = Uri.parse("https://spark.oit.umass.edu/webct/logonDisplay.dowebct"); 
            Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);
        }
     });

    websiteButton  = (Button) findViewById(R.id.button5);
    websiteButton.setOnClickListener(new View.OnClickListener() 
    {
        public void onClick(View arg0) 
        {
            Uri uri = Uri.parse("http://www.umass.edu/"); 
            Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent);
        }
     });




}
}

Directions File (Force Close happens when this classes is being opened)

package com.sammy.umass;

import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;


public class DirectionsScreenActivity extends ExpandableListActivity {
ExpandableListAdapter mAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set up our adapter
    mAdapter = new MyExpandableListAdapter();
    setListAdapter(mAdapter);
    registerForContextMenu(getExpandableListView());
}

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    menu.setHeaderTitle("Sample menu");
    menu.add(0, 0, 0, R.string.expandable_list_sample_action);
}

@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();

    String title = ((TextView) info.targetView).getText().toString();

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); 
        int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition); 
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos,
                Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); 
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }

    return false;
}

/**
 * A simple adapter which maintains an ArrayList of photo resource Ids. 
 * Each photo is displayed as an image. This adapter supports clearing the
 * list of photos and adding a new photo.
 *
 */
public class MyExpandableListAdapter extends BaseExpandableListAdapter {
    // Sample data set.  children[i] contains the children (String[]) for groups[i].
    private String[] groups = { "   Academic Buildings", "   Residential Buildings", "   Dining Commons", "   All Buildings A-Z" };
    private String[][] children = {
            { "Agricultural Engineering Bldg", "Army ROTC Bldg", "Arnold House", "(Studio) Arts Building" },
            { "Baker Hall", "Brett Hall", "Brooks Hall", "Brown Hall" },
            { "Berkshire", "Franklin","Hampden","Hampshire","Worcester" },
            { "Agricultural Engineering Bldg", "Army ROTC Bldg", "Arnold House", "(Studio) Arts Building" }
    };

    public Object getChild(int groupPosition, int childPosition) {
        return children[groupPosition][childPosition];
    }

    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    public int getChildrenCount(int groupPosition) {
        return children[groupPosition].length;
    }

    public TextView getGenericView() {
        // Layout parameters for the ExpandableListView
        AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, 64);

        TextView textView = new TextView(DirectionsScreenActivity.this);
        textView.setLayoutParams(lp);
        // Center the text vertically
        textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
        // Set the text starting position
        textView.setPadding(36, 0, 0, 0);
        return textView;
    }

    public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
            View convertView, ViewGroup parent) {
        TextView textView = getGenericView();
        textView.setText(getChild(groupPosition, childPosition).toString());
        return textView;
    }

    public Object getGroup(int groupPosition) {
        return groups[groupPosition];
    }

    public int getGroupCount() {
        return groups.length;
    }

    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
            ViewGroup parent) {
        TextView textView = getGenericView();
        textView.setText(getGroup(groupPosition).toString());
        return textView;
    }

    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }

    public boolean hasStableIds() {
        return true;
    }

}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:28:12+00:00Added an answer on May 26, 2026 at 6:28 am

    Have you added the DirectionScreenActivity to your Manifest file? If not, that could cause a fatal crash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had the following situation: main application has app.xaml, which sets the Style for
As it stands now, you can't reopen Engine classes contained within the engine's /app
I have other pages within my app preferences which are stored as separate files
We have an application which we licence to separate companies. The app is customised
I have 12 columns separated by a tab. How can I join them side-by-side?
An iPhone app which I am creating generates reports from a Core Data database
I'm trying to use DUnit, which came with RAD Studio XE2, to unit testing
I have a Django app with classes for different things such as Post, Quote,
I'm writing an app in modular way, so I can possibly reuse some of
I have setup a basic app which pulls down a JSON stream and displays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.