Java ActionBar实现引发异常
我正在为Android实现ActionBar。我的Java代码有困难。当我运行我的应用程序时,Eclipse在我的代码中抛出一个错误:Java ActionBar实现引发异常,java,android,android-actionbar,Java,Android,Android Actionbar,我正在为Android实现ActionBar。我的Java代码有困难。当我运行我的应用程序时,Eclipse在我的代码中抛出一个错误: package com.example.android.rssfeed; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; pu
package com.example.android.rssfeed;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class RssfeedActivity extends Activity implements
MyListFragment.OnItemSelectedListener { // this is the place where it shows me an error
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rssfeed);
}
//NEW
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.mainmenu, menu);
return true;
}
//NEW
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_refresh:
Toast.makeText(this, "Action refresh selected", Toast.LENGTH_SHORT)
.show();
break;
case R.id.action_settings:
Toast.makeText(this, "Action Settings selected", Toast.LENGTH_SHORT)
.show();
break;
default:
break;
}
return true;
}
}
我在错误所在的位置留下了注释。您的活动需要重写
MyListFragment.OnItemSelectedListener接口中的方法,否则它会显示编译器错误。它会抛出什么错误?