不要在android pulltorefresh和loadmore库中加载数据

不要在android pulltorefresh和loadmore库中加载数据,android,android-asynctask,Android,Android Asynctask,我下载并导入了这个库[ 一切正常。但是当我试图更改错误输出中的代码时。 注释出什么是有效的。我下面显示的不是工作。甚至日志也没有显示。我做错了什么 public class LoadMoreExampleActivity extends ListActivity { // list with the data to show in the listview private LinkedList<String> mListItems; // The data

我下载并导入了这个库[ 一切正常。但是当我试图更改错误输出中的代码时。 注释出什么是有效的。我下面显示的不是工作。甚至日志也没有显示。我做错了什么

public class LoadMoreExampleActivity extends ListActivity {

    // list with the data to show in the listview
    private LinkedList<String> mListItems;

    // The data to be displayed in the ListView
    private String[] mNames = { "Fabian", "Carlos", "Alex", "Andrea", "Karla",
            "Freddy", "Lazaro", "Hector", "Carolina", "Edwin", "Jhon",
            "Edelmira", "Andres" };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loadmore);

        mListItems = new LinkedList<String>();
        mListItems.addAll(Arrays.asList(mNames));

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, mListItems);

        setListAdapter(adapter);

        // set a listener to be invoked when the list reaches the end
        ((LoadMoreListView) getListView())
                .setOnLoadMoreListener(new OnLoadMoreListener() {
                    public void onLoadMore() {
                        // Do the work to load more items at the end of list
                        // here
                        new LoadDataTask().execute();
                    }
                });
    }

    private class LoadDataTask extends AsyncTask<String, Void, String> {
        String[] mass;
        @Override
        protected String doInBackground(String... strings) {
            Document doc;
            if (isCancelled()) {
                return null;
            }

            // Simulates a background task
//          try {
//              Thread.sleep(1000);
//          } catch (InterruptedException e) {
//          }
//          for (int i = 0; i < mNames.length; i++)
//              mListItems.add("string"+i);


            try {
                doc = Jsoup.connect(link).get();
                Elements eName = doc.select("name");

                for (int i = 0; i < eName.size(); i++) {
                    mListItems.add(eName.get(i).ownText());
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

            return null;
        }

        @Override
        protected void onPostExecute(String result) {

            mListItems.add("Added after load more");

            // We need notify the adapter that the data have been changed
            ((BaseAdapter) getListAdapter()).notifyDataSetChanged();

            // Call onLoadMoreComplete when the LoadMore task, has finished
            ((LoadMoreListView) getListView()).onLoadMoreComplete();

            super.onPostExecute(result);
        }

        @Override
        protected void onCancelled() {
            // Notify the loading more operation has finished
            ((LoadMoreListView) getListView()).onLoadMoreComplete();
        }
    }
}
公共类LoadMoreExampleActivity扩展了ListActivity{
//列出要在listview中显示的数据
私有链接列表;
//要在ListView中显示的数据
私有字符串[]mNames={“Fabian”、“Carlos”、“Alex”、“Andrea”、“Karla”,
“弗雷迪”、“拉扎罗”、“赫克托”、“卡罗莱纳”、“埃德温”、“约翰”,
“埃德米拉”、“安德烈斯”};
/**在首次创建活动时调用*/
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.loadmore);
mListItems=新链接列表();
mListItems.addAll(Arrays.asList(mNames));
ArrayAdapter=新的ArrayAdapter(此,
android.R.layout.simple_list_item_1,mListItems);
setListAdapter(适配器);
//设置在列表结束时调用的侦听器
((LoadMoreListView)getListView()
.setOnLoadMoreListener(新的OnLoadMoreListener(){
public void onLoadMore(){
//在列表末尾加载更多项
//这里
新建LoadDataTask().execute();
}
});
}
私有类LoadDataTask扩展了AsyncTask{
弦[]质量;
@凌驾
受保护的字符串背景(字符串…字符串){
文件文件;
如果(isCancelled()){
返回null;
}
//模拟后台任务
//试一试{
//睡眠(1000);
//}catch(InterruptedException e){
//          }
//对于(int i=0;i
您不会忘记连接到internet吗

<uses-permission android:name="android.permission.INTERNET"/>

您在代码中更改了什么?