E/AndroidRuntime: CRITICAL ERROR: main --- java code in an android app

I've been working on a map application and I've run into some issues. Can anyone help me figure out what's wrong with my code?

ERROR

10-25 01:37:41.296 28673-28673/com.onemap.activities E/AndroidRuntime: FATAL EXCEPTION: main
10-25 01:37:41.296 28673-28673/com.onemap.activities E/AndroidRuntime: Process: com.onemap.activities, PID: 28673
10-25 01:37:41.296 28673-28673/com.onemap.activities E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.onemap.activities/com.onemap.activities.OneMap}: android.view.InflateException: Binary XML file line #7: Error inflating class android.widget.TextView
...

ONEMAP.java

The issue seems to be at setContentView(R.layout.onemap);

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.onemap);

        AppUtilities.init(this);
        favDB = new FavouritesDBHandler(AppUtilities.getContext());

        this.scrollView = (SlidingMenu) findViewById(R.id.mScrollView);
        View mainContent = this.scrollView.getMainContent();
        OnClickListener clickListener = getClickListener();
        OnLongClickListener longClickListener = getLongClickListener();
       ... 
    }

MAINMENU.java

The error appears to be at

inflater.inflate(R.layout.menu_main, rl);

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = super.onCreateView(inflater, container, savedInstanceState);
        RelativeLayout rl = (RelativeLayout) v.findViewById(R.id.menu_content);
        inflater.inflate(R.layout.menu_main, rl);
       ...
    }

Here is an excerpt from my XML File:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.onemap.widgets.MapView
        xmlns:callout="http://schemas.android.com/apk/res/com.onemap.activities"
        android:id="@id/mMapView"
        calloutStyle="@xml/callout_style"
        initExtent="29454.233386372267 39831.55546813806 30038.01821247406 40758.313879574656"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        callout:layout="@layout/callout" />
   ...
</RelativeLayout>

Answer №1

You need to make some adjustments in how the views are set up. Here is the revised code for you:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {

    // Set the main view by replacing hello_world with the correct layout_name.xml file
    View v = inflater.inflate(R.layout.hello_world, container, false);

    // Set other views
    ViewHolder viewHolder = new ViewHolder();
    viewHolder.arrowUp = (ImageView) v.findViewById(R.id.iv_arrow_up);
    viewHolder.arrowDown = (ImageView) v.findViewById(R.id.iv_arrow_down);

    ListView menuList = (ListView) v.findViewById(R.id.menu_list);
    menuList.setOnItemClickListener(this);
    menuList.setOnScrollListener(this);
    menuList.setTag(viewHolder);

    MenuItem[] arrayMenuItem = new MenuItem[5];
    arrayMenuItem[0] = new MenuItem(0, "Services", R.mipmap.ic_menu_title_service);
    arrayMenuItem[1] = new MenuItem(1, getString(R.string.get_directions), R.mipmap.ic_directions);
    arrayMenuItem[2] = new MenuItem(2, getString(R.string.amenities), R.mipmap.ic_amenities);
    arrayMenuItem[3] = new MenuItem(3, "Others", R.mipmap.ic_menu_title_other);
    arrayMenuItem[4] = new MenuItem(4, getString(R.string.about), R.mipmap.ic_about);

    menuList.setAdapter(new MenuAdapter(getActivity(), arrayMenuItem));

    return v;
}

Consider moving the view holder code to your custom adapter MenuAdapter.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The active class in the Bootstrap carousel is not updating when trying to change

I am struggling to make the Twitter Bootstrap carousel function properly. Although the slides automatically change after the default timeout, the indicators do not switch the active class, resulting in my carousel failing to transition between slides. Ini ...

Does the first Ajax call always finish first in the order of Ajax calls?

In my code, I have an ajax call that triggers another ajax call based on its return value. The URL parameter of the second call is modified by the output of the first one. These two calls are interrelated as the first call feeds the URL parameter for the s ...

Spinning a CSS object around an axis

Trying to add a unique touch to my image rotation with CSS. While familiar with rotating around x, y, and z axis, I want to achieve a diagonal rotation this time. Wondering if there's a way to tweak the y axis for a more slanted effect on my image? ...

Attempting to modify the audio tag's src attribute with JavaScript

I've been doing online research for the past few weeks and have come across similar solutions to what I'm trying to achieve. However, due to my limited knowledge of javascript, I am struggling to implement them effectively. My goal is to have an ...

Android is pulling an incorrect phone number from the system

I have tried numerous solutions and code snippets, but unfortunately my issue still remains unresolved. The phone numbers being retrieved from contacts appear to be random 3-4 digit numbers instead of the actual contact phone numbers. When I try to dial th ...

Initiating, halting, and rejuvenating a timer in JavaScript

Here is a simple code snippet where I'm experimenting with starting, stopping, and resetting a JavaScript timer. The goal is to have a timer running on a page that sends a message once it reaches the end of its countdown before restarting. The stop b ...

Preventing a JavaScript timer function from executing multiple times when triggered by an 'in viewport' function

I am trying to create a website feature where a timer starts counting up once a specific div is scrolled into view. However, I am encountering an issue where scrolling away restarts the timer, and I would like the final value that the timer reaches to rema ...

What is a regex with a touch of greed in its capture

I am considering the following options: ' !This is a string! ' '!This is a string !' '! This is a string !' ' ! This is a string! ' ' ! This is a string ' For each of these scenarios, I aim to find ...

Ways to showcase a website within an HTML document using a URL?

Is it possible to show 2 webpages on a single aspx webpage? For instance, When a user opens the link for www.mywebsite.com, I would like to display both www.google.com and www.bing.com on my homepage. Behind the scenes, I will call two separate URLs an ...

Is there a way to modify the edit button to become a save button and include a cancel button?

Is there a way to toggle between an edit button and a save button, along with a cancel option? $('#edit').click(function() { $(this).hide(); $('#save, #cancel').show(); }); $('#cancel').click(function() { $('#ed ...

Storing information within AngularJS

As a newcomer to the world of coding and Angular, I am currently working on developing a calculator-style web application that includes a rating section in the footer. My main concern revolves around saving data so that it can be accessed by other users. T ...

Why is it that when I use require.js, all my modules appear to be loading at once when the page first

During the development of my single-page backbone app using requirejs, I encountered an issue when deploying to our beta server. The initial page load took around 20 seconds as it had to fetch all the necessary scripts. I initially believed that this dela ...

Restricting the fields in a $lookup operation in MongoDB

My Mongo object follows the schema provided below. { "_id" : "59fffda313d02500116e83bf::5a059c67f3ff3b001105c509", "quizzes" : [ { "topics" : [ ObjectId("5a05a1e1fc698f00118470e2") ], " ...

Unable to begin the previous project on my Mac, but it functions properly on Windows

After running npm i, I encountered the following error message which I am unsure how to resolve. I tried reinstalling Node.js, Python, and Pyenv, but the issue persists. Interestingly, the same version of Node.js on Windows runs the project without any p ...

Problem with ngStyle: Error indicating that the expected '}' is missing

I encountered an error in the Chrome console when trying to interpret the code below: <div [ngStyle]="{'width': '100%'; 'height': '100%'; 'background-size': 'cover'; 'background-repeat&ap ...

Ways to retrieve and filter out specific fields from a JSON dataset

Video Game Information Class: public class VideoGame { private String title; private int appID; private boolean downloaded; } Example of JSON data: My Implementation: public static VideoGame parseJson(String gameID) throws IOException { Strin ...

The functionality of the remove button in the jQuery Dropzone seems to be malfunction

I devised a user-friendly drag and drop feature for uploading images using the dropzone plugin. Here is the code snippet that I implemented: <script src="<?php echo base_url() ?>acc/assets/dropzone/dropzone.js"></script> <form actio ...

Mocking a Promise-returning dependency for a React Component in Jest

There's a React component I'm working on that has a dependency like so: import { fetchUsers } from '../../api/'; This function is a utility that returns a Promise. My challenge lies in trying to mock this dependency using Jest. I&apo ...

What is the method to retrieve a randomly generated class from an id?

Is there a way to target elements that have the class "my_class" within the element with the id of "info_id"? It's important to note that these elements may also have another class, which I'm not interested in selecting. <div id="info_id"> ...

Guide on changing image source using a function

I am looking to dynamically set the img src="" attribute using a JavaScript function that changes the image based on a variable and checks its values: Here is the JavaScript code in the file: function myFunctionstatus(){ var ledactual = document.getE ...