我目前有这个和 android 活动,但是当单击按钮时应用程序崩溃。我找不到哪里错了。
public class SearchActivity extends Activity implements OnClickListener{
private ListView recipes;
Intent intent;
Button button;
EditText input;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.searchlist);
button = (Button)findViewById(R.id.submit);
input = (EditText)findViewById(R.id.recipeName);
//recipes = (ListView)findViewById(R.id.recipes);
//recipes.setAdapter(new ArrayAdapter<String> (this, R.layout.main, getResources().getStringArray(R.array.BaconSandwich)));
button.setOnClickListener(this);
}
public void onClick(View clicked) {
if(clicked.getId() == R.id.submit) {
//recipes = (ListView)findViewById(R.array.recipes);
String value = input.getText().toString();
Toast.makeText(this, value, Toast.LENGTH_SHORT).show();
Intent i = new Intent(this, RecipeMethodActivity.class);
SearchActivity.this.startActivity(i);
}
}
}
该活动在android清单中设置,下一个活动为空白我得到的日志猫消息是:
RecipeMethodActivity onCreate() 中的错误。
我的 RecipeMethodActivity 是:
package com.finalyearproject.cookmefood;
import android.app.ListActivity;
import android.os.Bundle;
public class RecipeMethodActivity extends ListActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}