私はアンドロイドアプリを構築しようとしています。私の考えは、用語集アプリを作成することです。これは稼働していますが、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;
}
}