List of usage examples for android.widget FrameLayout removeViewAt
public void removeViewAt(int index)
From source file:com.dpcsoftware.mn.CategoryStats.java
public void renderGraph() { SQLiteDatabase db = DatabaseHelper.quickDb(this, 0); if (date == null) date = Calendar.getInstance().getTime(); String queryModifier = ""; if (isByMonth) queryModifier = " AND strftime('%Y-%m'," + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_DATAT + ") = '" + app.dateToDb("yyyy-MM", date) + "'"; Cursor c = db.rawQuery("SELECT " + Db.Table2.TABLE_NAME + "." + Db.Table2._ID + "," + Db.Table2.TABLE_NAME + "." + Db.Table2.COLUMN_NCAT + "," + Db.Table2.TABLE_NAME + "." + Db.Table2.COLUMN_CORCAT + "," + "SUM(" + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_VALORT + ")" + " FROM " + Db.Table1.TABLE_NAME + "," + Db.Table2.TABLE_NAME + " WHERE " + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_IDCAT + " = " + Db.Table2.TABLE_NAME + "." + Db.Table2._ID + " AND " + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_IDGRUPO + " = " + app.activeGroupId + queryModifier + " GROUP BY " + Db.Table1.TABLE_NAME + "." + Db.Table1.COLUMN_IDCAT + " ORDER BY " + Db.Table2.COLUMN_NCAT, null); float[] values = new float[c.getCount()]; int[] colors = new int[c.getCount()]; float total = 0; while (c.moveToNext()) { values[c.getPosition()] = c.getFloat(3); colors[c.getPosition()] = c.getInt(2); total += c.getFloat(3);/*from w w w . jav a2 s .c o m*/ } BarChart v = new BarChart(this, values, colors); v.setPadding(10, 10, 10, 10); FrameLayout graphLayout = ((FrameLayout) findViewById(R.id.FrameLayout1)); if (graphLayout.getChildCount() == 1) graphLayout.removeViewAt(0); graphLayout.addView(v); ListView lv = ((ListView) findViewById(R.id.listView1)); ((TextView) footer.findViewById(R.id.textView2)).setText(app.printMoney(total)); int days = 1; if (!isByMonth) { SimpleDateFormat dateF = new SimpleDateFormat("yyyy-MM-dd"); dateF.setTimeZone(TimeZone.getDefault()); Cursor cTemp = db.rawQuery("SELECT " + Db.Table1.COLUMN_DATAT + " FROM " + Db.Table1.TABLE_NAME + " WHERE " + Db.Table1.COLUMN_IDGRUPO + " = " + app.activeGroupId + " ORDER BY " + Db.Table1.COLUMN_DATAT + " DESC", null); try { cTemp.moveToFirst(); Date date2 = dateF.parse(cTemp.getString(0)); cTemp.moveToLast(); Date date1 = dateF.parse(cTemp.getString(0)); days = (int) Math.ceil((date2.getTime() - date1.getTime()) / (1000.0 * 24 * 60 * 60)) + 1; App.Log("" + days); } catch (Exception e) { e.printStackTrace(); } } else { Calendar cal = Calendar.getInstance(); cal.setTime(date); Calendar now = Calendar.getInstance(); if (cal.get(Calendar.MONTH) == now.get(Calendar.MONTH) && cal.get(Calendar.YEAR) == now.get(Calendar.YEAR)) days = now.get(Calendar.DAY_OF_MONTH); else days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); } ((TextView) footer2.findViewById(R.id.textView2)).setText(app.printMoney(total / days)); ((TextView) findViewById(R.id.textViewMonth)).setText(app.dateToUser("MMMM / yyyy", date)); if (adapter == null) { adapter = new CategoryStatsAdapter(this, c, total); lv.setAdapter(adapter); } else { adapter.changeCursor(c, total); adapter.notifyDataSetChanged(); } }
From source file:com.alexive.graphicalutils.fragments.RecyclerViewFragment.java
/** * Sets a view to be displayed when the list is empty with optional LayoutParams. * @param view Displayed when the list is empty. * @param params Information about how view's layout in the countainer. *//*from w w w . j a v a 2 s. c om*/ public void setEmptyView(View view, FrameLayout.LayoutParams params) { emptyView = view; isEmptyViewEmptyText = true; FrameLayout frameLayout = (FrameLayout) getView(); if (frameLayout == null) return; //In order to avoid having more than one emptyViews added to the layout if (frameLayout.getChildCount() > 2) frameLayout.removeViewAt(2); if (this.emptyText != null) frameLayout.findViewById(android.R.id.text1).setVisibility(View.GONE); if (params == null) { params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; } frameLayout.addView(view, 1, params); this.emptyViewAddedToLayout = true; actuallySetEmptyView(); }