即使在加载列表之前,ListView页脚也会显示

时间:2014-01-10 10:20:30

标签: android listview

我有一个从网上加载的项目列表。列表数据在后台加载时会运行动画。我需要将页脚视图添加到列表视图中。这很有效,期望在加载列表之前页脚视图可见。我已经尝试了几件事来规避这个问题。但它不会发生。我附上了代码和一个问题。请看看你是否可以帮助我。 enter image description here谢谢:)

listView = (ListView) findViewById(R.id.listView1);
        load = new Button(this);
        // load.setVisibility(View.GONE);
        // load.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
        // LayoutParams.WRAP_CONTENT));
        load.setBackground(getResources().getDrawable(R.drawable.dialogbutton));
        load.setTextColor(Color.parseColor("#ffffffff"));
        listView.addFooterView(load);

        load.setText("Show more Offers");

        load.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                loadingLayout.setVisibility(View.VISIBLE);
                loadigIcon.setVisibility(View.VISIBLE);
                loadingViewAnim.start();
                int start = end;
                end = end + 10;

                String urll = "http://www.squeakee.com/api/androidAPI/API.classSearchN.php?&lat=19.175655922901&long=72.83366315066814&sct=Mumbai&redius=6.4209294&type=view&catid=&srch=&spr=APP&mth=list";
                Log.d(TAG, "start=>" + start);
                url = urll + "&start=" + start + "&end=" + end;
                JsonObjectRequest request = new JsonObjectRequest(url.replace(
                        " ", "+"), null, new JSONRequest(), new JSONError());
                request.setShouldCache(false);
                requestQueue.add(request);

            }
        });
        mLaderInsideButton = (ImageButton) findViewById(R.id.refreshButton1);
        frameAnimation2 = (AnimationDrawable) mLaderInsideButton.getDrawable();
        // layoutShowMore = (LinearLayout) findViewById(R.id.ln_showmore);

        loadingLayout = (LinearLayout) findViewById(R.id.LinearLayout1);
        loadingLayout.setVisibility(View.GONE);

        loadigIcon = (ImageView) findViewById(R.id.imageView111);
        loadigIcon.setVisibility(View.GONE);

        loadigIcon.setBackgroundResource(R.drawable.loading_animation1);
        loadingViewAnim = (AnimationDrawable) loadigIcon.getBackground();

        LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        footerView = mLayoutInflater.inflate(R.layout.list_footer_view, null);
        entities = new ArrayList<OfferEntity>();
        url = getIntent().getExtras()
                .getString(SqueakeeMapListViewPager.APPTAG);
        url = url + "&start=" + INITAIL_START + "&end=" + ININTIAL_END;

        Log.d(TAG, "url=>" + url);
        listView.setOnItemClickListener(this);
        requestQueue = RequestQueueHolder.getQueue(this);
        mLaderInsideButton.setVisibility(View.VISIBLE);
        frameAnimation2.start();

        // use to parse jsonobjects
        JsonObjectRequest request = new JsonObjectRequest(
                url.replace(" ", "+"), null, new JSONRequest(), new JSONError());
        request.setShouldCache(false);
        request.setRetryPolicy(new DefaultRetryPolicy(20000,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        adapter = new OfferAdapterList(this, entities, false);
        listView.setAdapter(adapter);
        requestQueue.add(request);

1 个答案:

答案 0 :(得分:0)

如果列表视图中显示至少1个项目,则会显示ListView页脚。

如果列表视图为空,则不会显示页脚。

Can i set a footer to an empty listview in android?

在答案中添加Abby的评论。

引用

问题是我在加载列表之前设置了适配器,当加载列表时我调用了notifyDataSetChanged。我在第一次加载列表时调整代码来设置适配器,之后调用notifyDataSetChanged。像魅力一样工作