@Override public void onResume() { super.onResume(); // get the page preferences String viewCounter = prefs.getString("ViewCounter", "Counters"); // change the text for the page TextView header = (TextView) findViewById(R.id.textCounters); // create the list of counters for the page ListView listCounter = (ListView) findViewById(R.id.listCounters); String[][] counter; // find the counters in he database if (viewCounter.equals("Counters")) { counter = databaseExtra.getCounteringChampions(champion); } else { counter = databaseExtra.getCounteredByChampions(champion); } // if its not null, display the counters if (counter != null) { header.setPadding(0, 0, 0, 0); header.setGravity(Gravity.LEFT); header.setBackgroundResource(0); header.setTextColor(Color.WHITE); header.setText(champion + " " + viewCounter); if (!viewCounter.equals("Counters")) { header.setText(champion + " is " + viewCounter); } listCounter.setAdapter(new CounterAdapter(counter, getHashmap(counter))); } else { header.append("\nNo information in the database."); header.setPadding(20, 20, 20, 20); header.setGravity(Gravity.CENTER); header.setBackgroundResource(R.drawable.bgskills); header.setTextColor(Color.BLACK); listCounter.setAdapter(null); } }
@Override public void onPause() { super.onPause(); databaseExtra.close(); }