我想做一个图像查看应用程序,但我无法全屏显示图像。我可以从 SD 卡加载它,但是当我单击图像时,应用程序崩溃了。谁能帮我?
这是我的代码:
public class MainActivity extends Activity {
private ImageAdapter imageAdapter;
ArrayList<String> f = new ArrayList<String>();// list of file paths
ArrayList<Integer> resultList = getIntegerArray(f);
File[] listFile;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getFromSdcard();
GridView imagegrid = (GridView) findViewById(R.id.ImageGrid);
imageAdapter = new ImageAdapter();
imagegrid.setAdapter(imageAdapter);
imagegrid.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Intent i = new Intent(getApplicationContext(), FullImageActivity.class);
i.putExtra("id", position);
startActivity(i);
}
});
我的 FullImageActivity
public class FullImageActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.full_image);
// get intent data
Intent i = getIntent();
// Selected image id
int position = i.getExtras().getInt("id");
ImageAdapter imageAdapter = new ImageAdapter();
ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
imageView.setImageResource(resultList.get(position));
}
}
我的 LogCat 错误消息
06-19 11:41:28.456: E/AndroidRuntime(12723): FATAL EXCEPTION: main
06-19 11:41:28.456: E/AndroidRuntime(12723): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.testandroid4/com.example.testandroid4.MainActivity$FullImageActivity}; have you declared this activity in your AndroidManifest.xml?
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.app.Activity.startActivityForResult(Activity.java:3370)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.app.Activity.startActivityForResult(Activity.java:3331)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.app.Activity.startActivity(Activity.java:3566)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.app.Activity.startActivity(Activity.java:3534)
06-19 11:41:28.456: E/AndroidRuntime(12723): at com.example.testandroid4.MainActivity$1.onItemClick(MainActivity.java:61)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.widget.AbsListView$1.run(AbsListView.java:3423)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.os.Handler.handleCallback(Handler.java:725)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.os.Handler.dispatchMessage(Handler.java:92)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.os.Looper.loop(Looper.java:137)
06-19 11:41:28.456: E/AndroidRuntime(12723): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-19 11:41:28.456: E/AndroidRuntime(12723): at java.lang.reflect.Method.invokeNative(Native Method)
06-19 11:41:28.456: E/AndroidRuntime(12723): at java.lang.reflect.Method.invoke(Method.java:511)
06-19 11:41:28.456: E/AndroidRuntime(12723): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-19 11:41:28.456: E/AndroidRuntime(12723): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-19 11:41:28.456: E/AndroidRuntime(12723): at dalvik.system.NativeStart.main(Native Method)