private void populateListViews() { // THIS HERE WILL POPULATE BOTH TEAM LIST VIEWS // Create list of items Cursor cursor = db.getTeams(); ArrayList<String> values = new ArrayList<String>(); if (cursor != null && cursor.getCount() != 0) { cursor.moveToFirst(); while (!cursor.isAfterLast()) { values.add(cursor.getString(cursor.getColumnIndex("Team_Names"))); cursor.moveToNext(); } } // Build Adapter ArrayAdapter<String> t1adapter = new ArrayAdapter<String>( this, // Context R.layout.teamlistviews, // Layout to use values); // Items to be displayed // Configure the List View ListView t1list = (ListView) findViewById(R.id.listView1); t1list.setAdapter(t1adapter); cursor.close(); }
/* public void helppdf() { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("H:\\GitHub\\StaTap\\StaTapAlpha\\")); intent.setType("application/pdf"); PackageManager pm = getPackageManager(); List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0); if (activities.size() > 0) { startActivity(intent); } else { // Do something else here. Maybe pop up a Dialog or Toast } } */ public void getGames() { Cursor cursor = db.getGameIDs(); values = new ArrayList<HomeListData>(); if (cursor != null && cursor.getCount() != 0) { cursor.moveToFirst(); while (!cursor.isAfterLast()) { HomeListData data = new HomeListData(); int gid = cursor.getInt(0); data.gametitle = db.getGameTitle(gid); data.team1 = db.getGameT1(gid); data.team2 = db.getGameT2(gid); values.add(data); cursor.moveToNext(); } } cursor.close(); }
public void create(View view) { if (editTeam.getText().toString().trim().length() == 0) { String errormessage = "Error: Team name cannot be blank"; Toast.makeText(CreateTeam.this, errormessage, Toast.LENGTH_SHORT).show(); return; } String Team_Name = editTeam.getText().toString(); if (Team_Name.matches("[a-zA-Z ]*")) { String message = "Team " + editTeam.getText().toString() + " was added to the database"; editTeam.setText(""); db.addTeam(Team_Name); Toast.makeText(CreateTeam.this, message, Toast.LENGTH_SHORT).show(); populateListViews(); } else { Toast.makeText(CreateTeam.this, "Invalid characters in Team Name", Toast.LENGTH_SHORT).show(); } }
@Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.delete: View view = ((AdapterView.AdapterContextMenuInfo) info).targetView; LinearLayout linearLayoutParent = (LinearLayout) view; TextView tv1 = (TextView) linearLayoutParent.getChildAt(0); TextView tv2 = (TextView) linearLayoutParent.getChildAt(1); TextView tv3 = (TextView) linearLayoutParent.getChildAt(2); String gamename = tv1.getText().toString(); String team1 = tv2.getText().toString(); String team2 = tv3.getText().toString(); Toast.makeText(HomeScreen.this, gamename, Toast.LENGTH_SHORT).show(); db.delGame(gamename, team1, team2); refresh(); return true; default: return super.onContextItemSelected(item); } }
public void test(View view) { String test; test = Integer.toString(db.getGames()); Toast.makeText(HomeScreen.this, test, Toast.LENGTH_SHORT).show(); }
public void deleteTeam(String teamname2) { String teamname; teamname = teamname2; db.delTeam(teamname); populateListViews(); }