所以我得到这个错误,说“xy无法解析为类型”和“类型KalandActivity的方法onCreateOptionsMenu(菜单)必须覆盖或实现超类型方法”代码写在另一台计算机上并在那个上运行良好。我导入它并遇到了很多问题。我尝试了一些我在网上找到的解决方案,但似乎没有任何帮助。还有其他类也有问题。有人可以提一些建议吗?
package hu.treasurefinder;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import android.R;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;
public class KalandActivity extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_kaland);
TextView cim = (TextView) findViewById(R.id.cimView);
final ImageView kep = (ImageView) findViewById(R.id.kepView);
TextView szoveg = (TextView) findViewById(R.id.szovegView);
Intent param = getIntent();
Kaland kaland = (Kaland)param.getSerializableExtra("kaland");
cim.setText("2");
cim.setText(kaland.getNev());
szoveg.setText(kaland.getLeiras());
AsyncTask<String,Void,byte[]> task = new AsyncTask<String,Void,byte[]>() {
@Override
protected byte[] doInBackground(String... kep) {
URL url;
try {
url = new URL("http://www.programozas-oktatas.hu/kaland/"+kep[0]);
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int readBytes;
while ((readBytes = is.read(buffer)) != -1) {
baos.write(buffer, 0, readBytes);
}
is.close();
return baos.toByteArray();
} catch (IOException ex) {
return null;
}
}
@Override
protected void onPostExecute(byte[] result) {
super.onPostExecute(result);
Bitmap bmp = BitmapFactory.decodeByteArray(result, 0, result.length);
Bitmap resizedBitmap = Bitmap.createScaledBitmap(bmp, kep.getWidth(), kep.getHeight(), true);
kep.setImageBitmap(resizedBitmap);
}
};
task.execute(kaland.getKep());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.kaland, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}