Search code examples
androideclipseandroid-inflate

Android Inflater crashes


I am trying to build an android app. My idea is to create a glossary-app, and It has been up and running, but when I tried to add a Spinner, it crashed. Now I have removed the Spinner, but the app still crashes.

05-21 10:51:29.970: E/AndroidRuntime(22736): android.view.InflateException: Couldn't resolve menu item onClick handler onLanguageButtonClick in class se.inceptive.irebglossary.MainActivity
05-21 10:51:29.970: E/AndroidRuntime(22736):    at se.inceptive.irebglossary.MainActivity.onCreateOptionsMenu(MainActivity.java:58)

And this is presented at line 58:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

Any help on this is very appreciated

MainActivity.java

package se.inceptive.irebglossary;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.widget.TextView;
import android.content.Intent;
import se.inceptive.irebglossary.DisplayDescription;

public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
//    private ArrayAdapter<String> arrayAdapter;
private ListView termsListView;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    termsListView = (ListView) findViewById(R.id.termsListView);



 // Initialize the terms array
    Term [] items = {
            new Term(1, "Acceptance", "The process of assessing whether a system satisfies all its requirements", false, "Acceptans", ""),
            new Term(2, "Acceptance test", "A test that assesses whether a system satisfies all its requirements", false, "Acceptans test", ""),
            new Term(3, "Activity diagram", "A diagram type in UML which models the flow of actions in a system or in a component including data flows and areas of responsibility where necessary", false, "Aktivitets diagram", ""),
            new Term(4, "Actor", "1. Generally in RE: A person, a system or a technical device in the context of a system that interacts with the system.2. Especially in goal-oriented RE: a person, a system or a technical device that may act and process information in order to achieve some goals", false, "Aktör", ""),
    };
    ArrayAdapter<Term> adapter = new ArrayAdapter<Term>(this,android.R.layout.simple_list_item_1, items);
    termsListView.setAdapter(adapter);

    termsListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                long id) {

            String item = ((TextView)view).getText().toString();

            Intent intent = new Intent(view.getContext(), DisplayDescription.class);
            intent.putExtra(EXTRA_MESSAGE, item);
            startActivity(intent);

        }
    });
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
}

Solution

  • You seem to have specified the onClick handler for one of your menu items (in the XML) to be onLanguageButtonClick, but you have not provided the implementation for the onLanguageButtonClick in your activity code.