Android : ListFragment 持续加载

Android : ListFragment loading continuously

我正在将 class 扩展到 ListFragment。下面我贴亲戚。

我的问题是,我在运行时没有遇到任何错误,但在输出中它仍在加载页面。

输出:

Administration.java:

public class Administration extends ListFragment {


    int[] img = { R.drawable.project, R.drawable.user, R.drawable.group,
            R.drawable.roles, R.drawable.news, R.drawable.document };

    private String item[] = { "Project", "Users", "Group",
            "Roles and Permission", "News", "Documents" };

    @Override  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,  
        Bundle savedInstanceState) {    

         return super.onCreateView(inflater, container, savedInstanceState);  
    }

    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        getListView().setDividerHeight(2);
        getListView().setAdapter(new BindDataAdapter(getActivity(), img, item));
    }

    @SuppressWarnings("deprecation")
    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);

        for (int a = 0; a < l.getChildCount(); a++) {
            l.getChildAt(a).setBackgroundColor(Color.TRANSPARENT);
        }

    }

}

我没有使用 listFragment.I 中的任何布局 使用 BindDataAdapter.java

中的布局

BindDataAdapter.java:

public class BindDataAdapter extends BaseAdapter {
    Activity mLocal;
    int[] imgArray;
    String titleA[];
    LayoutInflater mLayoutInflater;

    public BindDataAdapter(Activity administration, int[] imageArray, String[] title) {
        mLocal = administration;
        imgArray = imageArray;
        titleA = title;
        mLayoutInflater = (LayoutInflater) administration
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }



    public int getCount() {
        return imgArray.length;
    }  

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }

    private class Holder {
        ImageView image;
        TextView textView;
    }

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

        Holder holder = null;
        if (convertView == null) {
            convertView = mLayoutInflater.inflate(R.layout.activity_list, null);
            holder = new Holder();
            holder.image = (ImageView) convertView.findViewById(R.id.iamge);
            holder.textView = (TextView) convertView.findViewById(R.id.text1);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.image.setBackgroundResource(imgArray[position]);
        holder.textView.setText(titleA[position]);
        return convertView;
    }

}

activity_list.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/whitelist"
    android:orientation="horizontal"
     >

    <ImageView
        android:id="@+id/iamge"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_margin="4dp"
        android:contentDescription="@string/app_name" >
    </ImageView>

    <TextView
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="20dp"
        android:padding="@dimen/padding_medium"
        android:paddingLeft="10dp"
        android:text="@string/hello_world"
        android:textColor="@android:color/black"
        android:textStyle="bold" 

        />

</LinearLayout>    

不知道为什么一直在加载。任何帮助主要是 appreciated.Thank 你。

可能显示进度条是 ListFragment 的默认内置进度。因此,在将 ListView 的适配器设置为:

后,使用 setListShown 关闭内置的不确定进度条
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
     .....
     setListShown(true);
}