Android Inflater崩溃
问题描述:
我是新来的论坛,我相信我犯了一个很大的错误,我的代码(某处)。Android Inflater崩溃
我正在尝试构建一个android应用程序的第一次,没有经验的Java或应用程序创建之前,所以请裸露在我身边。
我的想法是创建词汇表应用程序,它已启动并正在运行,但是当我尝试添加微调器时,它崩溃了。现在我已经移除了Spinner,但该应用程序仍然崩溃。
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)
,这是发表在第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;
}
任何帮助是非常赞赏
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;
}
}
答
你似乎已经指定其中一个菜单项的onClick处理程序(在th e XML)为onLanguageButtonClick
,但您尚未在活动代码中提供onLanguageButtonClick
的实施。
+0
非常感谢。那里确实有一个onClick。现在帮助删除它。 – Odecif
你能显示你的R.menu.main xml吗? – WarrenFaith