listview中的java.lang.IllegalStateException错误

时间:2017-06-15 02:05:56

标签: android listview

我不知道崩溃堆栈跟踪。我收到了java.lang.IllegalStateException错误。但是没有提示哪些代码会产生这些错误。

Google Play控制台的崩溃报告

java.lang.IllegalStateException: 
  at android.widget.ListView.layoutChildren(ListView.java:1618)
  at android.widget.AbsListView.onTouchUp(AbsListView.java:4039)
  at android.widget.AbsListView.onTouchEvent(AbsListView.java:3832)
  at android.view.View.dispatchTouchEvent(View.java:9945)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2666)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2344)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2672)
  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2358)
  at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:411)
  at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1810)
  at android.app.Activity.dispatchTouchEvent(Activity.java:3065)
  at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:0)
  at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:373)
  at android.view.View.dispatchPointerEvent(View.java:10165)
  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4446)
  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4314)
  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3914)
  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3880)
  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4007)
  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3888)
  at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4064)
  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3914)
  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3880)
  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3888)
  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861)
  at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6257)
  at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6196)
  at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6157)
  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6360)
  at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:192)
  at android.os.MessageQueue.nativePollOnce(MessageQueue.java:0)
  at android.os.MessageQueue.next(MessageQueue.java:323)
  at android.os.Looper.loop(Looper.java:136)
  at android.app.ActivityThread.main(ActivityThread.java:6123)
  at java.lang.reflect.Method.invoke(Method.java:0)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)

Activity_filemanager.java

中有一个列表视图
public class Activity_filemanager extends AppCompatActivity
{
    ArrayList <FiledataEx> FileListArray = new ArrayList <FiledataEx>();
    ArrayList<String>  excludeArray = new ArrayList <String> (); 
    ListView lv;
    MyFileListAdapter adapter; 
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_securedelete);
        lv = (ListView) findViewById(R.id.lv_filelist);

        FileListArray = CSDCard.getFileList(m_path, m_strFilter,excludeArray);

        adapter = new MyFileListAdapter(this,FileListArray,cb_preview.isChecked() );   
        lv.setAdapter(adapter);

        lv.setOnItemClickListener(new OnItemClickListener()
        {
            @Override
            public void onItemClick(AdapterView<?> a, View v, int position, long id) 
            {
                FileItem_Click(position);
            }
        });     
    } 

MyFileListAdapter.java

public class MyFileListAdapter extends BaseAdapter  {

    private LayoutInflater mInflater;
    Context context ;
    ArrayList <FiledataEx> FileListArray;
    final String TAG="adapter";
    public ImageLoader imageLoader;
    public boolean bPreview ;

    public MyFileListAdapter(Context context,ArrayList <FiledataEx> FileListArray, boolean bPreview) {

        mInflater = LayoutInflater.from(context);
        this.context = context;
        this.FileListArray = FileListArray;

        imageLoader = new ImageLoader(context);
        this.bPreview = bPreview;
    }
    public View getView(int position, View convertView, ViewGroup parent) 
    {
        ViewHolder holder;
        boolean bDisable = false;
        File imgFile;
        String strFullPath="";

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.listfile_detail, null);
            holder = new ViewHolder();

            holder.tv_filename = (TextView) convertView.findViewById(R.id.tv_filename2);
        holder.tv_filedate = (TextView) convertView.findViewById(R.id.tv_filedate);
        holder.iv_fileicon = (ImageView) convertView.findViewById(R.id.imageView1);
        holder.cb_selected = (CheckBox )convertView.findViewById(R.id.cb_selected);

        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    FiledataEx r = getFiledata(position);

    holder.cb_selected.setVisibility(View.VISIBLE);
    holder.tv_filename.setText(r.strFilename);
    holder.tv_filedate.setText(r.strFilesize_kB  + " , " +    r.strFileDate );
    holder.cb_selected.setChecked(r.IsChecked() );
    holder.cb_selected.setTag(position);
    holder.cb_selected.setOnClickListener( new OnClickListener() 
    {
        @Override
        public void onClick(View v) {
            CheckBox c = (CheckBox) v;
            int row_id = (Integer) v.getTag();
            FiledataEx r = FileListArray.get(row_id);
            r.setSelected(c.isChecked());
            FileListArray.set(row_id, r);
        }
    });
    return convertView;
}

listfile_deail.xml

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingLeft="8dp"
        android:paddingRight="8dp" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:adjustViewBounds="true"
            android:padding="8dp"
            android:scaleType="centerCrop" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:orientation="vertical"
            android:paddingLeft="8dp"
            android:paddingRight="8dp" >

            <TextView
                android:id="@+id/tv_filename2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="IMG_20150101_120029.jpg"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="#0000FF"
                    android:textSize="16sp" />

                <TextView
                    android:id="@+id/tv_filedate"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="right"
                    android:text="TextView" />

        </LinearLayout>

         <CheckBox
             android:id="@+id/cb_selected"
             android:layout_width="44dp"
             android:layout_height="44dp"
             android:layout_gravity="center_vertical"
             android:focusable="false"
             android:background="@drawable/cb_selector"
            android:button="@null"
              />

    </LinearLayout>

</LinearLayout>

0 个答案:

没有答案