List of usage examples for android.widget ListView addFooterView
public void addFooterView(View v)
From source file:com.irccloud.android.activity.PastebinsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC));/*from w w w . ja va 2 s .com*/ cloud.recycle(); } setContentView(R.layout.ignorelist); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar)); getSupportActionBar().setElevation(0); } if (savedInstanceState != null && savedInstanceState.containsKey("adapter")) { try { page = savedInstanceState.getInt("page"); Pastebin[] pastebins = (Pastebin[]) savedInstanceState.getSerializable("adapter"); for (Pastebin p : pastebins) { adapter.addPastebin(p); } adapter.notifyDataSetChanged(); } catch (Exception e) { page = 0; adapter.clear(); } } footer = getLayoutInflater().inflate(R.layout.messageview_header, null); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(adapter); listView.addFooterView(footer); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) { canLoadMore = false; new FetchPastebinsTask().execute((Void) null); } } }); listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { final Pastebin p = (Pastebin) adapter.getItem(i); Intent intent = new Intent(PastebinsActivity.this, PastebinViewerActivity.class); intent.setData(Uri.parse(p.url + "?id=" + p.id + "&own_paste=" + (p.own_paste ? "1" : "0"))); startActivity(intent); } }); Toast.makeText(this, "Tap a pastebin to view full text with syntax highlighting", Toast.LENGTH_LONG).show(); }
From source file:com.irccloud.android.activity.UploadsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (ColorFormatter.file_uri_template != null) template = UriTemplate.fromTemplate(ColorFormatter.file_uri_template); super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC));//w w w. ja v a 2s . c o m cloud.recycle(); } if (Build.VERSION.SDK_INT >= 14) { try { java.io.File httpCacheDir = new java.io.File(getCacheDir(), "http"); long httpCacheSize = 10 * 1024 * 1024; // 10 MiB HttpResponseCache.install(httpCacheDir, httpCacheSize); } catch (IOException e) { Log.i("IRCCloud", "HTTP response cache installation failed:" + e); } } setContentView(R.layout.ignorelist); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar)); getSupportActionBar().setElevation(0); } if (savedInstanceState != null && savedInstanceState.containsKey("cid")) { cid = savedInstanceState.getInt("cid"); to = savedInstanceState.getString("to"); msg = savedInstanceState.getString("msg"); page = savedInstanceState.getInt("page"); File[] files = (File[]) savedInstanceState.getSerializable("adapter"); for (File f : files) { adapter.addFile(f); } adapter.notifyDataSetChanged(); } footer = getLayoutInflater().inflate(R.layout.messageview_header, null); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(adapter); listView.addFooterView(footer); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) { canLoadMore = false; new FetchFilesTask().execute((Void) null); } } }); listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { final File f = (File) adapter.getItem(i); AlertDialog.Builder builder = new AlertDialog.Builder(UploadsActivity.this); builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB); final View v = getLayoutInflater().inflate(R.layout.dialog_upload, null); final EditText messageinput = (EditText) v.findViewById(R.id.message); messageinput.setText(msg); final ImageView thumbnail = (ImageView) v.findViewById(R.id.thumbnail); v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (messageinput.hasFocus()) { v.post(new Runnable() { @Override public void run() { v.scrollTo(0, v.getBottom()); } }); } } }); if (f.mime_type.startsWith("image/")) { try { thumbnail.setImageBitmap(f.image); thumbnail.setVisibility(View.VISIBLE); thumbnail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(UploadsActivity.this, ImageViewerActivity.class); i.setData(Uri.parse(f.url)); startActivity(i); } }); thumbnail.setClickable(true); } catch (Exception e) { e.printStackTrace(); } } else { thumbnail.setVisibility(View.GONE); } ((TextView) v.findViewById(R.id.filesize)).setText(f.metadata); v.findViewById(R.id.filename).setVisibility(View.GONE); v.findViewById(R.id.filename_heading).setVisibility(View.GONE); builder.setTitle("Send A File To " + to); builder.setView(v); builder.setPositiveButton("Send", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String message = messageinput.getText().toString(); if (message.length() > 0) message += " "; message += f.url; dialog.dismiss(); if (getParent() == null) { setResult(Activity.RESULT_OK); } else { getParent().setResult(Activity.RESULT_OK); } finish(); NetworkConnection.getInstance().say(cid, to, message); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog d = builder.create(); d.setOwnerActivity(UploadsActivity.this); d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); d.show(); } }); }
From source file:com.money.manager.ex.common.AllDataListFragment.java
private void renderFooter() { this.footer = (LinearLayout) View.inflate(getActivity(), R.layout.item_generic_report_2_columns, null); TextView txtColumn1 = (TextView) footer.findViewById(R.id.textViewColumn1); TextView txtColumn2 = (TextView) footer.findViewById(R.id.textViewColumn2); txtColumn1.setText(R.string.total);/* w w w. j a v a2 s .c o m*/ txtColumn1.setTypeface(null, Typeface.BOLD_ITALIC); txtColumn2.setText(R.string.total); txtColumn2.setTypeface(null, Typeface.BOLD_ITALIC); ListView listView = getListView(); listView.addFooterView(footer); }
From source file:org.mariotaku.twidere.fragment.StatusFragment.java
@Override void setListHeaderFooters(final ListView list) { list.addFooterView(mStatusView); }
From source file:org.deviceconnect.android.deviceplugin.health.fragment.HealthCareDeviceSettingsFragment.java
private void onClickScanButton() { final ListView listView = (ListView) mRootView.findViewById(R.id.device_list_view); Button button = (Button) mRootView.findViewById(R.id.button_scan); if (mIsScanning) { getManager().stopScanBle();// w w w . j a va 2s.c o m button.setText(R.string.heart_rate_setting_button_start); listView.removeFooterView(mFooterView); mIsScanning = false; } else { getManager().startScanBle(); button.setText(R.string.heart_rate_setting_button_stop); listView.addFooterView(mFooterView); mIsScanning = true; } }
From source file:net.naonedbus.fragment.CustomInfiniteListFragement.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final ListView listView = getListView(); mLoaderView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_loader, null); mLoaderView.setEnabled(false);/*from w w w . j a v a 2 s .c o m*/ mLoaderView.setClickable(false); mLoaderView.setFocusable(false); mLoaderView.setFocusableInTouchMode(false); addOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(final AbsListView view, final int scrollState) { } @Override public void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount, final int totalItemCount) { final int lastInScreen = firstVisibleItem + visibleItemCount; if ((lastInScreen == totalItemCount) && listView.getAdapter() != null && !mHasError) { onLoadMoreItems(); } else if (lastInScreen < totalItemCount) { mHasError = false; mLoaderView.setVisibility(View.VISIBLE); } } }); listView.addFooterView(mLoaderView); }
From source file:com.maxleap.mall.fragments.ShopFragment.java
private void initUI(View view) { mContext = getActivity();/*from w ww .j a v a 2s . c o m*/ mainActivity = (MainActivity) getActivity(); Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); mEditView = (TextView) toolbar.findViewById(R.id.edit); if (mAdapter != null && mAdapter.isInEditMode()) { mEditView.setText(R.string.frag_shop_toolbar_edit_done); } else { mEditView.setText(R.string.frag_shop_toolbar_edit); } toolbar.findViewById(R.id.edit).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAdapter.isInEditMode()) { mEditView.setText(R.string.frag_shop_toolbar_edit); mAdapter.setInEditMode(false); } else { mEditView.setText(R.string.frag_shop_toolbar_edit_done); mAdapter.setInEditMode(true); } } }); ListView listView = (ListView) view.findViewById(R.id.shop_list); View footView = LayoutInflater.from(mContext).inflate(R.layout.view_shop_list_foot, null); mTotalPayView = (TextView) footView.findViewById(R.id.total_pay); mTotalPayView.setText(String.format(getString(R.string.product_price), mTotalPay)); mPayButton = (Button) footView.findViewById(R.id.pay_button); mPayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (UserManager.getInstance().getCurrentUser() == null) { Intent toAccountIntent = new Intent(mContext, LoginActivity.class); startActivity(toAccountIntent); } else { StringBuilder productIds = new StringBuilder(); StringBuilder productNames = new StringBuilder(); for (int i = 0; i < mProductDatas.size(); i++) { productIds.append(mProductDatas.get(i).getId()).append(","); productNames.append(mProductDatas.get(i).getTitle()).append(","); } Map<String, String> dimensions = new HashMap<>(); dimensions.put("ProductIds", productIds.toString()); dimensions.put("ProductName", productNames.toString()); dimensions.put("TotalBuyCount", "" + mProductDatas.size()); dimensions.put("Price", "" + mTotalPay); dimensions.put("UserName", MLUser.getCurrentUser().getUserName()); MLAnalytics.logEvent("Balance", 1, dimensions); Intent intent = new Intent(mContext, OrderConfirmActivity.class); startActivity(intent); } } }); view.findViewById(R.id.to_main_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mainActivity.selectTab(0); } }); listView.addFooterView(footView); listView.setEmptyView(view.findViewById(R.id.empty)); if (mProductDatas == null) { mProductDatas = new ArrayList<>(); } if (mAdapter == null) { mAdapter = new ShopProductAdapter(mContext, mProductDatas, new ShopProductAdapter.CountListener() { @Override public void onCountChanged() { if (mProductDatas.size() == 0) { mEditView.setVisibility(View.GONE); return; } else { mEditView.setVisibility(View.VISIBLE); } int totalPay = 0; for (ProductData productData : mProductDatas) { totalPay += productData.getPrice() * productData.getCount(); } mTotalPay = totalPay / 100f; mTotalPayView.setText(String.format(getString(R.string.product_price), mTotalPay)); } }); } listView.setAdapter(mAdapter); listView.setOnItemClickListener(this); }
From source file:cgeo.geocaching.CacheListActivity.java
private void initAdapter() { final ListView listView = getListView(); registerForContextMenu(listView);/*from w w w . j a v a 2 s . c om*/ adapter = new CacheListAdapter(this, cacheList, type); adapter.setFilter(currentFilter); if (listFooter == null) { listFooter = getLayoutInflater().inflate(R.layout.cacheslist_footer, listView, false); listFooter.setClickable(true); listFooter.setOnClickListener(new MoreCachesListener()); listFooterText = ButterKnife.findById(listFooter, R.id.more_caches); listView.addFooterView(listFooter); } setListAdapter(adapter); adapter.setInverseSort(currentInverseSort); adapter.forceSort(); }
From source file:me.johnmh.boogdroid.ui.BugInfoFragment.java
@Override public void onViewCreated(final View view, final Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final AppCompatActivity activity = (AppCompatActivity) getActivity(); ListView listView = getListView(); listView.addHeaderView(mainView);/* w w w. j a v a 2 s. c o m*/ final AdapterComment adapter = new AdapterComment(activity, bug.getComments()); EditText editCommentFilter = (EditText) mainView.findViewById(R.id.editCommentFilter); editCommentFilter.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } @Override public void afterTextChanged(Editable s) { } }); View footer = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.footer_comment, null, false); final EditText editComment = (EditText) footer.findViewById(R.id.editComment); editComment.setText(""); Button addComment = (Button) footer.findViewById(R.id.addComment); addComment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String comment = JSONObject.quote(editComment.getText().toString()); final Server server = bug.getProduct().getServer(); final BugzillaTask task = new BugzillaTask(server, "Bug.add_comment", "'id':" + bug.getId() + ", 'comment': " + comment, new Util.TaskListener() { @Override public void doInBackground(final Object response) { if (server.isUseJson()) { doJsonParse(response); } else { doXmlParse(response); } } private void doJsonParse(Object response) { //TODO: It returns the new comment id. So you could only reload that one try { System.out.println(response); } catch (final Exception e) { e.printStackTrace(); } } private void doXmlParse(Object response) { //TODO: It returns the new comment id. So you could only reload that one try { System.out.println(response); } catch (final Exception e) { e.printStackTrace(); } } @Override public void onPostExecute(final Object response) { updateView(); bug.loadComments(); } }); task.execute(); } }); listView.addFooterView(footer); setListAdapter(adapter); bug.setAdapterComment(adapter, activity, this); }