English 中文(简体)
Log误? 应用图像图例意外停止使用
原标题:Logcat error? The application Image View Example has stopped unexpectedly

Hi Now I am download Image view source Its working fine....but if I change grid view to gallery view in this coding....The emulator indicate these error: The application ImageView Example(Process ImageView Example.ImageView Example) has stopped unexpectedly.

logcat also indicate error.....what mistake I made in this coding....Pls help me....I will post my coding and logcat error also....

我完整的项目编码:

package ImageViewExample.ImageViewExample;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
//import android.widget.GridView;
import android.widget.ImageView;
import android.widget.AdapterView.OnItemClickListener;

public class ImageViewExample extends Activity {
  /** Called when the activity is first created. */
  private Cursor imagecursor, actualimagecursor;
  private int image_column_index, actual_image_column_index;
  Gallery imagegrid;
  private int count;
  @Override
  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        init_phone_image_grid();
  }
  private void init_phone_image_grid() {
        String[] img = { MediaStore.Images.Thumbnails._ID };
        imagecursor = managedQuery(
  MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, img, null,
  null, MediaStore.Images.Thumbnails.IMAGE_ID + "");
        image_column_index = imagecursor
  .getColumnIndexOrThrow(MediaStore.Images.Thumbnails._ID);
        count = imagecursor.getCount();
        imagegrid = (Gallery) findViewById(R.id.PhoneImageGrid);
        imagegrid.setAdapter(new ImageAdapter(getApplicationContext()));
        imagegrid.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView parent, View v,
  int position, long id) {
                    System.gc();
                    String[] proj = { MediaStore.Images.Media.DATA };
                    actualimagecursor = managedQuery(
  MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,
  null, null, null);
                    actual_image_column_index = actualimagecursor
  .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                    actualimagecursor.moveToPosition(position);
                    String i = actualimagecursor.getString(actual_image_column_index);
                    System.gc();
                    Intent intent = 
                        new Intent(getApplicationContext(),ViewImage.class);
                    intent.putExtra("filename", i);
                    startActivity(intent);
              }
        });
  }


  public class ImageAdapter extends BaseAdapter {
        private             Context mContext;
        public ImageAdapter(Context c) {
              mContext = c;
        }
        public int getCount() {
              return count;
        }
        public Object getItem(int position) {
              return position;
        }
        public long getItemId(int position) {
              return position;
        }
        public View getView(int position,View convertView,ViewGroup parent) {
              System.gc();
              ImageView i = new ImageView(mContext.getApplicationContext());
              if (convertView == null) {
                    imagecursor.moveToPosition(position);
                    int id = imagecursor.getInt(image_column_index);
                    i.setImageURI(Uri.withAppendedPath( 
               MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, ""+ id));
                    i.setScaleType(ImageView.ScaleType.CENTER_CROP);
                    i.setLayoutParams(new Gallery.LayoutParams(92, 92));
              }
              else {
                    i = (ImageView) convertView;
              }
              return i;
        }
     }
      }

In this coding i am changing gridview to gallery only.....

日志错误:

04-12 04:28:24.314: DEBUG/AndroidRuntime(623): >>>>>>>>>>>>>> AndroidRuntime START 
<<<<<<<<<<<<<<
04-12 04:28:24.325: DEBUG/AndroidRuntime(623): CheckJNI is ON
04-12 04:28:24.784: DEBUG/AndroidRuntime(623): --- registering native functions ---
04-12 04:28:26.305: DEBUG/AndroidRuntime(623): Shutting down VM
04-12 04:28:26.325: DEBUG/dalvikvm(623): Debugger has detached; object registry had 1 
entries
04-12 04:28:26.355: INFO/AndroidRuntime(623): NOTE: attach of thread  Binder Thread    
#3  failed
04-12 04:28:27.345: DEBUG/AndroidRuntime(631): >>>>>>>>>>>>>> AndroidRuntime START 
<<<<<<<<<<<<<<
04-12 04:28:27.345: DEBUG/AndroidRuntime(631): CheckJNI is ON
04-12 04:28:27.814: DEBUG/AndroidRuntime(631): --- registering native functions ---
04-12 04:28:29.424: INFO/ActivityManager(67): Starting activity: Intent { 
act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 
cmp=ImageViewExample.ImageViewExample/.ImageViewExample }
04-12 04:28:29.554: DEBUG/AndroidRuntime(631): Shutting down VM
04-12 04:28:29.615: DEBUG/dalvikvm(631): Debugger has detached; object registry had 1  
entries
04-12 04:28:29.724: INFO/AndroidRuntime(631): NOTE: attach of thread  Binder Thread 
#3  failed
04-12 04:28:29.954: INFO/ActivityManager(67): Start proc 
ImageViewExample.ImageViewExample for activity   
ImageViewExample.ImageViewExample/.ImageViewExample: pid=638 uid=10050 gids={}
04-12 04:28:30.204: DEBUG/SntpClient(67): request time failed: 
java.net.SocketException: Address family not supported by protocol
04-12 04:28:31.234: DEBUG/AndroidRuntime(638): Shutting down VM
04-12 04:28:31.234: WARN/dalvikvm(638): threadid=1: thread exiting with uncaught 
exception (group=0x4001d800)
04-12 04:28:31.295: ERROR/AndroidRuntime(638): FATAL EXCEPTION: main
04-12 04:28:31.295: ERROR/AndroidRuntime(638): java.lang.RuntimeException: Unable to 
start activity 
ComponentInfo{ImageViewExample.ImageViewExample/ImageViewExample.ImageViewExample.
ImageViewExample}: android.view.InflateException: Binary XML file line #11: Error 
inflating class GalleryView
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at  
android.os.Looper.loop(Looper.java:123)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.app.ActivityThread.main(ActivityThread.java:4627)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
java.lang.reflect.Method.invokeNative(Native Method)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at   
java.lang.reflect.Method.invoke(Method.java:521)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at    
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at   
dalvik.system.NativeStart.main(Native Method)
04-12 04:28:31.295: ERROR/AndroidRuntime(638): Caused by: 
android.view.InflateException: Binary XML file line #11: Error inflating class 
GalleryView
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at    
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at  
android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at   
android.app.Activity.setContentView(Activity.java:1647)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
ImageViewExample.ImageViewExample.ImageViewExample.onCreate(ImageViewExample.java:28)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at   
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     ... 11 more
04-12 04:28:31.295: ERROR/AndroidRuntime(638): Caused by: 
java.lang.ClassNotFoundException: android.view.GalleryView in loader 
dalvik.system.PathClassLoader[/data/app/ImageViewExample.ImageViewExample-2.apk]
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at    
java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.view.LayoutInflater.createView(LayoutInflater.java:466)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at 
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView
(PhoneLayoutInflater.java:66)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     at   
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-12 04:28:31.295: ERROR/AndroidRuntime(638):     ... 20 more
04-12 04:28:31.345: WARN/ActivityManager(67):   Force finishing activity 
ImageViewExample.ImageViewExample/.ImageViewExample
04-12 04:28:31.874: WARN/ActivityManager(67): Activity pause timeout for 
HistoryRecord{44016758 ImageViewExample.ImageViewExample/.ImageViewExample}
04-12 04:28:43.174: WARN/ActivityManager(67): Activity destroy timeout for     
HistoryRecord{44016758 ImageViewExample.ImageViewExample/.ImageViewExample}
04-12 04:31:00.255: DEBUG/dalvikvm(67): GC_FOR_MALLOC freed 9773 objects / 543760 
bytes in 223ms
04-12 04:33:30.214: DEBUG/SntpClient(67): request time failed: 
java.net.SocketException: Address family not supported by protocol
04-12 04:33:31.434: WARN/InputManagerService(67): Window already focused, ignoring 
focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43f4f678
04-12 04:33:31.914: INFO/Process(638): Sending signal. PID: 638 SIG: 9
04-12 04:33:31.954: INFO/ActivityManager(67): Process 
ImageViewExample.ImageViewExample (pid 638) has died.
04-12 04:38:30.225: DEBUG/SntpClient(67): request time failed: 
java.net.SocketException: Address family not supported by protocol
04-12 04:43:30.234: DEBUG/SntpClient(67): request time failed:   
java.net.SocketException: Address family not supported by protocol
04-12 04:48:30.245: DEBUG/SntpClient(67): request time failed: 
java.net.SocketException: Address family not supported by protocol
最佳回答

页: 1

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签