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 Javascript code I wrote is unable to detect the array element that was initially defined in Python

Trying to launch a new browser window through Selenium using driver.execute_script("window.open('');") However, the goal is to open a specific link provided by the user. For this purpose, extracted the link input from an array and inc ...

Guide to building a React project with an outdated edition of Create React App

Currently, I'm following an older tutorial to learn React, and as a result, I need to set up a project using Create React App version 1.5.2. I successfully installed <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="204352454 ...

How can state be shared between sibling components in React?

As someone who is relatively new to React, I am seeking guidance on the proper method of passing states between components. While I did come across a similar inquiry on Stack Overflow, I would appreciate if someone could provide a specific solution for my ...

Implementing server authentication with Faye in Node.js

As a complete newbie to node.js and faye, I'm struggling with the basics and not sure what questions to ask. This is how my faye server setup looks like, running on Nodejitsu: var http = require('http'), faye = require('faye' ...

failure of svg spinning

I'm currently working with an SVG file and attempting to incorporate a spinning animation similar to loaders and spinners. However, I am facing an issue where the rotating radius is too large and I am struggling to control it effectively. CSS: .image ...

Which is better: using multiple makeStyles or just one in Material UI?

Uncertain about the best approach in this situation. Is it acceptable to generate styles using makeStyles for each component individually, or would it be better to create one in the base component and simply pass down class names? ...

Encountering UnreachableBrowserException with Selenium Marionette driver on second attempt to launch the browser

Experimenting with the Selenium Marionette WebDriver is my current project. I am trying to sequentially open multiple Marionette drivers within my application, as shown below: MarionetteDriver driver = new MarionetteDriver(); // performing some actions dr ...

What steps can I take to prevent already selected options from being chosen in a Vue.js HTML form?

Among my json data, I have a list of all inventories: { "status": true, "data": [ { "inv_id": 1, "name": "Arts" }, { "inv_id": 2, "name": "web" }, { "inv_id": 3, "name": "mobileapp" }, { "inv_id": 4, "name": "ws" }, { "inv_id": 5, ...

Selenium encountering issue with selecting the second option in a radio button

This is the current selection: <input type="radio" tabindex="0" name="accounts" onclick="populateSelection();" value="MC Credit ***388.37***" checked=""> CSS-selector: body > form > span > table > tbody > tr:nth-child(5) > td.wall ...

Developing an identical design and layout but utilizing a distinct domain name for the company

After being given the task of creating a website identical to an existing one with a different domain name on WordPress, I proposed using the parent HTML source code or cloning it to speed up the project. The client agreed, explaining that starting from sc ...

Having trouble setting the `variant='dense'` for material-ui Toolbar – it remains at a height of 64px no matter what

Implemented a hello world AppBar/Toolbar with the variant='dense' style. import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import registerServiceWorker from './registerServiceWo ...

WebDriver - Optimizing wait times for text display on the web page without relying on locators

After taking an action with WebDriver, such as clicking a button, a specific text will appear on the page. We do not have the locator element for the text, but we know exactly what text will be displayed. Can you recommend a method to wait for this parti ...

"Learn how to deactivate the submit button while the form is being processed and reactivate it once the process is

I have been searching for solutions to this issue, but none seem to address my specific concern. Here is the HTML in question: <form action=".."> <input type="submit" value="download" /> </form> After submitting the form, it takes a ...

Tips for verifying that input is provided in a text field when the checkbox is marked

Can someone help me with validating a form where the user must enter data in a text field if they check a checkbox? I have JavaScript code for checkbox validation, but need assistance with text field validation. Thank you! $(document).ready(function () ...

Headless ChromeDriver encounters ElementNotVisibleException

I am new to using Selenium. I require a headless browser as the project will be integrated with Jenkins. After some consideration, I opted for ChromeDriver in Headless mode. While utilizing ChromeDriver in regular mode, I can successfully interact with al ...

What is causing my page to refresh when making an Ajax call? (e.g. triggering the servlet request again

I'm currently learning about RESTful web service implementation using Java in my development environment, which consists of Netbeans IDE with GlassFish v3. Within my project, I have a specific page URL called /inventoryList, which is mapped to the In ...

What is the best way to include a dialog div within a form tag?

I am facing an issue with a JQuery dialog on my webpage. The data entered into the dialog seems to get lost because the dialog is placed outside the form tag. Here is how it appears: https://i.stack.imgur.com/fnb07.png So far, I have attempted this soluti ...

Having issues with Json stringification and serializing arrays

Having an issue with Json when using serializeArray. An example of my HTML form: <form action="" method="post" name="myForm"> ID: <input type="text" name="id" /><br/> State (XX): <input type="text" name="state" /><br/> <p ...

Creating an object property conditionally in a single line: A quick guide

Is there a more efficient way to conditionally create a property on an object without having to repeat the process for every different property? I want to ensure that the property does not exist at all if it has no value, rather than just being null. Thi ...

Saving Arrays through an Input Form in JavaScript

I am working with an HTML form that looks like the following: <div class="form-group"> <label for="first_name">1st Name</label> <input type="text" id="first_name" placeholder="First Name" class="form-control"/> </div> ...