StackView的适配器中getMatrix的StackOverFlow错误

时间:2014-07-19 01:38:47

标签: android listview adapter

我有一个问题在这里我无法找出这个错误说什么,这里我有一个适配器对于我的ListView,当它有一些数据时,它工作正常,但当列表变大,我得到此错误:

 07-18 22:48:37.989: I/dalvikvm(1078): threadid=1: stack overflow on call to   
 Landroid/view/HardwareCanvas;.<init>:V
 07-18 22:48:37.989: I/dalvikvm(1078):   method requires 4+20+4=28 bytes, fp is 
 0xb2e98310 (16 left)
 07-18 22:48:37.999: I/dalvikvm(1078):   expanding stack end (0xb2e98300 to 0xb2e98000)
 07-18 22:48:37.999: I/dalvikvm(1078): Shrank stack (to 0xb2e98300, curFrame is   
 0xb2e985d0)



07-18 21:15:30.313: E/AndroidRuntime(2610): Process: com.lifemate.lmmessenger, PID: 
2610
07-18 21:15:30.313: E/AndroidRuntime(2610): java.lang.StackOverflowError
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.View.getMatrix(View.java:9265)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at  
android.view.ViewGroup.invalidateChild(ViewGroup.java:4251)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.View.invalidate(View.java:10878)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.widget.TextView.invalidateDrawable(TextView.java:4855)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:344)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.graphics.drawable.ShapeDrawable.updateShape(ShapeDrawable.java:372)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.graphics.drawable.ShapeDrawable.onBoundsChange(ShapeDrawable.java:294)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.graphics.drawable.Drawable.setBounds(Drawable.java:156)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.View.draw(View.java:14445)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.View.getDisplayList(View.java:13362)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.View.getDisplayList(View.java:13404)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.View.draw(View.java:14182)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.ViewGroup.drawChild(ViewGroup.java:3103)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.View.getDisplayList(View.java:13357)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.View.getDisplayList(View.java:13404)
07-18 21:15:30.313: E/AndroidRuntime(2610):     at 
android.view.View.draw(View.java:14182)

此外似乎有时会抛出此错误! :

07-18 22:21:18.173: E/AndroidRuntime(19673): FATAL EXCEPTION: main
07-18 22:21:18.173: E/AndroidRuntime(19673): Process: com.lifemate.lmmessenger, PID:   
19673
07-18 22:21:18.173: E/AndroidRuntime(19673): java.lang.StackOverflowError
07-18 22:21:18.173: E/AndroidRuntime(19673):    at 
android.view.ViewRootImpl.scheduleTraversals(ViewRootImpl.java:973)
07-18 22:21:18.173: E/AndroidRuntime(19673):    at 
android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:898)
07-18 22:21:18.173: E/AndroidRuntime(19673):    at 
android.view.ViewGroup.invalidateChild(ViewGroup.java:4320)
07-18 22:21:18.173: E/AndroidRuntime(19673):    at 
android.view.View.invalidate(View.java:10878)
07-18 22:21:18.173: E/AndroidRuntime(19673):    at  
android.widget.TextView.invalidateDrawable(TextView.java:4855)
07-18 22:21:18.173: E/AndroidRuntime(19673):    at 
android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:344)
07-18 22:21:18.173: E/AndroidRuntime(19673):    at 
android.graphics.drawable.Drawable.setBounds(Drawable.java:153)
07-18 22:21:18.173: E/AndroidRuntime(19673):    at 
android.view.View.draw(View.java:14445)

这是我的适配器,我删除了额外的条件,只留下1个条件,因为即使只有1个LayoutType它也会出现。

public ChatAdapter(Context context, int layout, Cursor c, String[] from,
        int[] to, int flags) {
    super(context, layout, c, from, to, flags);
     threadPoolExecutor =
                new ThreadPoolExecutor(
                        corePoolSize,
                        maxPoolSize,
                        keepAliveTime,
                        TimeUnit.MILLISECONDS,
                        new LinkedBlockingQueue<Runnable>()
                        );


    this.mContext = context;
    this.mCursor=c;
    mLayoutInflater = (LayoutInflater) 
 mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    System.out.println("ReCreatingAdapter");
}


//  
//}



@Override
public int getCount() {
    return mCursor.getCount();
}

 @Override
 public int getViewTypeCount() {
     return 4;
 }


@Override
  public int getItemViewType(int position) {

     mCursor.moveToPosition(position);

     FileDetector = mCursor.getString(mCursor.getColumnIndex("isfile"));

     type=(mCursor.getString(mCursor.getColumnIndex("isfile")).split("\\@ADAT")[0]);

     int chooser =0;
     if(!"".equals(FileDetector)){
      if(type.equals("image")|| type.equals("video") || type.equals("Unknown")){
        switch (type) {
    case "image":
        chooser=IMAGE_VIEW_TYPE;
        break;
    case "video":
        chooser=VIDEO_VIEW_TYPE;
        break;
    case "Unknown": 
        chooser=UNKNOWN_VIEW_TYPE;
    case "audio":
        chooser=AUDIO_VIEW_TYPE;
        }

     }else{
         System.out.println("its outside detectorand unknown");
         chooser=UNKNOWN_VIEW_TYPE;
     }

    }else{
        chooser=TEXT_VIEW_TYPE;
       }
     System.out.println("type"+type);
     return chooser;

 }

@Override
public Object getItem(int position) {
    return mCursor.getString(position);
}

@Override
public long getItemId(int position) {
    return mCursor.getPosition();
}



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

   ViewHolder holder = null;

    int Demand = getItemViewType(position);
    System.out.println("Demand :"+Demand);
     if (convertView == null || convertView.getTag() == null) {

        holder = new ViewHolder();

    System.out.println("ConvertView null");

          switch (Demand) {


          case 0:

                 convertView = mLayoutInflater.inflate(R.layout.single_chat_text, null);

                 holder.wrapper = (LinearLayout) convertView.findViewById(R.id.wrapper);
                 holder.theName = (TextView) convertView.findViewById(R.id.MSGname);
                 holder.theImage = (ImageView)convertView.findViewById(R.id.MSGimage);
                 holder.lp = (FrameLayout.LayoutParams) holder.theName.getLayoutParams();
                 holder.paramsleft = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,Gravity.LEFT);
                 holder.paramsright = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,Gravity.RIGHT);
                 holder.theMessage = (TextView) convertView.findViewById(R.id.comment);

             break;

          }


    System.out.println("ConverView null");

    convertView.setTag((ViewHolder)holder);

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


if(holder.badge!=null){
    holder.badge.setVisibility(View.GONE);
    holder.badge.invalidate();
    holder.badge=null;
}

    String imagenamer= (mCursor.getString(mCursor.getColumnIndex("username")).split("\\@"))[0];
    int isright= Integer.valueOf(mCursor.getString(mCursor.getColumnIndex("isright")));

    switch (Demand) {


    case 0:
        // is Text

        holder.theMessage.setText(mCursor.getString(mCursor.getColumnIndex("message")));
        if(isright==0){
            holder.theMessage.setBackgroundResource(R.drawable.bubble_yellow);
        }else{
            holder.theMessage.setBackgroundResource(R.drawable.bubble_green);
        }
        holder.badge =  new BadgeView(mContext,holder.theMessage);

        break;

我很抱歉,如果它太大了,这里也是我的ListView:

 <?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:orientation="vertical" >


<ListView
    android:id="@+id/listView_multichat"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/form_multichat"
    android:layout_alignParentTop="true" 
    android:stackFromBottom="true"
    android:transcriptMode="alwaysScroll"

    >

</ListView>

<RelativeLayout
    android:id="@+id/form_multichat"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:orientation="vertical" >

   <LinearLayout
        android:id="@+id/bottom_write_bar_multichat"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:background="@drawable/message_bar" >

        <EditText
            android:id="@+id/TextFeild_multichat"
            android:layout_width="fill_parent"
            android:layout_height="45dp"
            android:layout_margin="5sp"
            android:layout_weight="0.13"
            android:background="@drawable/message_field"
            android:ems="10"
            android:hint="Write here"
            android:padding="5sp"
            android:textColor="@color/textFieldColor" >

            <requestFocus />
        </EditText>

        <Button
            android:id="@+id/SendText_multichat"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_margin="5sp"
            android:background="@drawable/send_button"
            android:paddingBottom="5sp"
            android:paddingLeft="15sp"
            android:paddingRight="15sp"
            android:paddingTop="5sp"
            android:text="Send"
            android:textColor="#FFF" />

         <Button
             android:id="@+id/ImportFile_multichat"
             android:layout_width="41dp"
             android:layout_height="fill_parent"
             android:layout_margin="5sp"
             android:background="@drawable/send_button"
             android:paddingBottom="5sp"
             android:paddingLeft="15sp"
             android:paddingRight="15sp"
             android:paddingTop="5sp"
             android:text="F"
             android:textColor="#FFF" />

    </LinearLayout>

 </RelativeLayout>

 <ImageView
    android:id="@+id/MSGTitle_multichat"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_gravity="center" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
    android:id="@+id/VideoFrame_multichat"
    android:layout_width="fill_parent"
    android:layout_height="300dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" 
    android:background="@drawable/abc_ab_solid_light_holo">

    <VideoView
        android:id="@+id/VideoPlayer_multichat"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center" />

    <Button
        android:id="@+id/videodismiss_multichat"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Back" 
        android:gravity="bottom"
        />

 </FrameLayout>
  </FrameLayout>

 <FrameLayout 

 android:layout_width="match_parent"
 android:layout_height="wrap_content" >



 <FrameLayout
        android:id="@+id/audioframe_multichat"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/abc_ab_solid_light_holo"
         >

        <LinearLayout
            android:id="@+id/linearLayout1_multichat"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:background="#75000000"
            android:orientation="vertical"
            android:paddingBottom="2dp"
            android:paddingTop="5dp" >

            <TextView
                android:id="@+id/trackTitle_multichat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:layout_marginRight="15dp"
                android:singleLine="true"
                android:text="@string/trackInitialValue"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:visibility="visible" 
                android:textSize="15sp"
                />

            <View
                android:layout_width="fill_parent"
                android:layout_height="2dip"
                android:layout_margin="5dp"
                android:background="#5033ff33" />





            <LinearLayout
                android:id="@+id/artistLayout1_multichat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="12dp"
                android:orientation="horizontal" >

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:paddingBottom="2dp"
                    android:paddingTop="2dp"
                    android:scaleType="fitCenter"
                    android:src="@drawable/artist24" />

                <TextView
                    android:id="@+id/trackArtist_multichat"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="15dp"
                    android:singleLine="true"
                    android:text="@string/artistInitialValue"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:visibility="visible" 
                    android:textSize="12sp"
                    />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/artistLayout1_multichat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="12dp"
                android:orientation="horizontal" >

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:paddingBottom="2dp"
                    android:paddingTop="2dp"
                    android:scaleType="fitCenter"
                    android:src="@drawable/album24" />

                <TextView
                    android:id="@+id/trackAlbum_multichat"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="90dp"
                    android:singleLine="true"
                    android:text="@string/albumInitialValue"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    android:visibility="visible"
                    android:textSize="12sp"
                     />
            </LinearLayout>

            <SeekBar
                android:id="@+id/songprogressBar_multichat"
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:progressDrawable="@drawable/progress_bar_full" />

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="35dp"
                android:background="@drawable/header_bg100"
                android:gravity="center_vertical" >
        <TextView
                android:id="@+id/trackDuration_multichat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="8dp"
                android:layout_marginRight="15dp"
                android:text="@string/durationInitialValue"
                android:textAppearance="?android:attr/textAppearanceSmall" />

        <TextView
                android:id="@+id/trackPostionSeparator_multichat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@id/trackDuration"
                android:layout_alignBaseline="@id/trackDuration"
                android:text="@string/trackPostionSeparator"
                android:textAppearance="?android:attr/textAppearanceSmall" />


        <TextView
                android:id="@+id/trackCurrPostion_multichat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@id/trackPostionSeparator"
                android:layout_alignBaseline="@id/trackDuration"
                android:text="@string/currPositionInitialValue"
                android:textAppearance="?android:attr/textAppearanceSmall"/>
                <ImageView
                    android:id="@+id/playButton_multichat"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentTop="true"
                    android:contentDescription="@string/play"
                    android:paddingTop="2dp"
                    android:src="@drawable/play96" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:layout_alignParentRight="true" >

                    <ImageView
                        android:id="@+id/separator_multichat"
                        android:layout_width="wrap_content"
                        android:layout_height="fill_parent"
                        android:scaleType="fitXY"
                        android:src="@drawable/separator" />
                </LinearLayout>

            </RelativeLayout>

        </LinearLayout>
                    <Button
 android:id="@+id/audiodismiss_multichat"
 style="?android:attr/buttonStyleSmall"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentRight="true"
 android:layout_alignParentTop="true"
 android:text="Back"
 android:layout_gravity="right" 

/>


        </FrameLayout>



    </FrameLayout>



</RelativeLayout>

这是我的single_chat_text.xml:

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

 <FrameLayout 
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
>

  <TextView
      android:id="@+id/MSGname"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="TextView"
       />

  <ImageView
      android:id="@+id/MSGimage"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="right"

      />

<RelativeLayout
    android:id="@+id/wrapper"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:orientation="vertical"
    >


    <TextView
        android:id="@+id/comment"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dip"
        android:background="@drawable/bubble_yellow"
        android:textColor="@android:color/primary_text_light" />

</RelativeLayout>

</FrameLayout>

</RelativeLayout>

关于什么是这个错误的任何帮助是真正感谢的。感谢

0 个答案:

没有答案