Ошибка LogCat?Пример просмотра изображения приложения неожиданно остановился - PullRequest
0 голосов
/ 13 апреля 2011

Привет. Теперь я загружаю исходный вид изображения. Работает нормально .... но если я поменяю вид сетки на вид галереи в этой кодировке .... Эмулятор показывает следующие ошибки: Приложение ImageView Example (Process ImageView Example.ImageViewПример) неожиданно остановился.

logcat также указывает на ошибку ..... какую ошибку я допустил в этой кодировке .... Пожалуйста, помогите мне .... Я также опубликую свою ошибку кодирования и logcat ....

моя полная кодировка проекта:

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;
        }
     }
      }

В этой кодировке я изменяю gridview только на галерею .....

logcat error:

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 Ответ

2 голосов
/ 13 апреля 2011

Измените тег GalleryView на Gallery в вашем файле res \ layout \ main.xml.

...