List of usage examples for android.widget ListView addFooterView
public void addFooterView(View v)
From source file:io.jari.geenstijl.Blog.java
void initUI(final Artikel[] artikelen, final boolean doSwitchState) { final PullToRefreshLayout mPullToRefreshLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout); runOnUiThread(new Runnable() { public void run() { ListView siteSwitch = (ListView) findViewById(R.id.site_switcher); String domain = getSharedPreferences("geenstijl", 0).getString("gsdomain", "www.geenstijl.nl"); if (domain.equals("www.geenstijl.nl")) { actionBar.setTitle("GeenStijl"); siteSwitch.setItemChecked(0, true); } else { actionBar.setTitle("GeenStijl.TV"); siteSwitch.setItemChecked(1, true); }//from w w w . j a va 2 s . c o m final ListView show = (ListView) findViewById(R.id.show); if (showTopPadding == 0) showTopPadding = show.getPaddingTop(); show.setScrollingCacheEnabled(false); show.setAdapter(new ArtikelAdapter(Blog.this, 0, artikelen)); //#HOLOYOLO if (Build.VERSION.SDK_INT >= 19) { SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); show.setPadding(0, showTopPadding + config.getPixelInsetTop(true), 0, 0); } //hiding the actionbar when scrolling show.setOnScrollListener(new AbsListView.OnScrollListener() { int mLastFirstVisibleItem = 0; public void onScrollStateChanged(AbsListView view, int scrollState) { } public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (view.getId() == show.getId()) { final int currentFirstVisibleItem = show.getFirstVisiblePosition(); if (currentFirstVisibleItem > mLastFirstVisibleItem && actionBar.isShowing()) { enableImmersive(true, show); } else if (currentFirstVisibleItem < mLastFirstVisibleItem && !actionBar.isShowing()) { enableImmersive(false, show); } mLastFirstVisibleItem = currentFirstVisibleItem; } } }); //footer if (show.getAdapter().getClass() != HeaderViewListAdapter.class) { //check if footer is present, if not, add it View footer = getLayoutInflater().inflate(R.layout.meerrr, null); final View button = footer.findViewById(R.id.more); if (Build.VERSION.SDK_INT >= 19) { ViewGroup.LayoutParams params = button.getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); ((ViewGroup.MarginLayoutParams) params).bottomMargin = config.getPixelInsetBottom(); } button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { button.setEnabled(false); mPullToRefreshLayout.setRefreshing(true); enableImmersive(false, show); forceNoImmersive = true; new Thread(new Runnable() { public void run() { try { final Artikel[] artikelen2 = API.getArticles(true, true, getApplicationContext()); runOnUiThread(new Runnable() { public void run() { ListView show = (ListView) findViewById(R.id.show); //java is such a beautiful language *cough* ArtikelAdapter artikelAdapter = (ArtikelAdapter) ((HeaderViewListAdapter) show .getAdapter()).getWrappedAdapter(); artikelAdapter.update(artikelen2); mPullToRefreshLayout.setRefreshComplete(); button.setVisibility(View.GONE); forceNoImmersive = false; } }); } catch (final Exception e) { e.printStackTrace(); runOnUiThread(new Runnable() { public void run() { button.setEnabled(true); mPullToRefreshLayout.setRefreshComplete(); forceNoImmersive = false; Crouton.makeText(Blog.this, e.getLocalizedMessage() == null ? "Onbekende fout" : e.getLocalizedMessage(), Style.ALERT).show(); } }); } } }).start(); } }); show.addFooterView(footer); } //grreat success! if (doSwitchState) switchState(STATE_SHOW); else mPullToRefreshLayout.setRefreshComplete(); } }); }