ZygoteInit $ MethodAndArgsCaller.run()行:762 eclipse中找不到源错误

时间:2015-01-26 09:33:02

标签: android eclipse listview android-adapter android-debug

`我正在创建一个应用程序,其中我从Web服务中获取数据(服务工作正常)并在listview中显示它。为此,我已经创建了自定义适配器类和自定义布局文件。现在每当我尝试将适配器设置为listview时,它都会给我错误:

  

ZygoteInit $ MethodAndArgsCaller.run()行:762未找到来源   错误

我在下面的java文件中提到了这一行。我不确定eclispe正在谈论哪个来源。我该如何解决它? 提前谢谢。

这是我的适配器类。

公共类CategoryAdapter扩展了BaseAdapter {

 Context context;
 List<Category> rowItems;


    CategoryAdapter(Context context, List<Category> rowItems){
    this.context = context;

    this.rowItems = rowItems;}

    private class ViewHolder {
          ImageView image;
          TextView cname;
          TextView pid;

         }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        LayoutInflater mInflater = (LayoutInflater) context
                .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
              if (convertView == null) {
               convertView = mInflater.inflate(R.layout.categorylist, null);
               holder = new ViewHolder();

              holder.image = (ImageView)convertView.findViewById(R.id.cat_image);
              holder.cname = (TextView)convertView.findViewById(R.id.cname);
              holder.pid =(TextView)convertView.findViewById(R.id.pid);

              Category citems = new Category();
                citems = rowItems.get(position);


               holder.cname.setText(citems.getName());
               holder.pid.setText(citems.getId());

               convertView.setTag(holder);}
               else {
                   holder = (ViewHolder) convertView.getTag();
                  }

                  return convertView;
                 }

这是xml文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="2dp" >

    <ImageView
        android:id="@+id/cat_image"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_marginTop="14dp"
        android:contentDescription="@string/String1"
        android:paddingLeft="10dp"
        android:paddingRight="10dp" />

    <TextView
        android:id="@+id/cname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_toRightOf="@+id/cat_image"
        android:paddingBottom="10dp"

        />

    <TextView
        android:id="@+id/pid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/cname"
        android:layout_below="@+id/cname"

         />

    </RelativeLayout>

JAVA文件

protected void onPostExecute(Void result) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
            //final ArrayAdapter adapter = new ArrayAdapter(this,
             //       R.layout.categorylist, arrayList);
               // listView.setAdapter(adapter);
            listView = (ListView) findViewById(R.id.listView1);
              CategoryAdapter adapter = new CategoryAdapter(getApplicationContext(), categoryname);
              listView.setAdapter(adapter);

如果我评论最后一行listview.setAdapter,则错误不会来。

基本上它在布局文件或适配器类中缺少某些资源。但是我无法弄清楚我错过了什么。我对此并不十分肯定。 categoryname是一个列表名称。

恢复时,应用程序崩溃了。 logcat的

01-26 15:40:19.824: E/AndroidRuntime(3127): FATAL EXCEPTION: main
01-26 15:40:19.824: E/AndroidRuntime(3127): android.content.res.Resources$NotFoundException: String resource ID #0x1
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.content.res.Resources.getText(Resources.java:242)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.content.res.MiuiResources.getText(MiuiResources.java:125)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.TextView.setText(TextView.java:3864)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at com.example.ecommerce.CategoryAdapter.getView(CategoryAdapter.java:59)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.AbsListView.obtainView(AbsListView.java:2207)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1247)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.ListView.onMeasure(ListView.java:1159)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.View.measure(View.java:15891)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:477)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.View.measure(View.java:15891)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5035)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.View.measure(View.java:15891)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5035)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.View.measure(View.java:15891)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5035)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2208)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.View.measure(View.java:15891)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1957)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1156)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1336)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1056)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5542)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.Choreographer.doFrame(Choreographer.java:532)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.os.Handler.handleCallback(Handler.java:730)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.os.Looper.loop(Looper.java:137)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at android.app.ActivityThread.main(ActivityThread.java:5162)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at java.lang.reflect.Method.invokeNative(Native Method)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at java.lang.reflect.Method.invoke(Method.java:525)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:756)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:572)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at miui.dexspy.DexspyInstaller.main(DexspyInstaller.java:171)
01-26 15:40:19.824: E/AndroidRuntime(3127):     at dalvik.system.NativeStart.main(Native Method)

0 个答案:

没有答案