Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Recycler View in Main Activity #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Scorecounter/.idea/caches/gradle_models.ser
Binary file not shown.
113 changes: 0 additions & 113 deletions Scorecounter/.idea/codeStyles/Project.xml

This file was deleted.

22 changes: 0 additions & 22 deletions Scorecounter/.idea/gradle.xml

This file was deleted.

14 changes: 0 additions & 14 deletions Scorecounter/.idea/misc.xml

This file was deleted.

12 changes: 0 additions & 12 deletions Scorecounter/.idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions Scorecounter/.idea/vcs.xml

This file was deleted.

Binary file modified Scorecounter/app/release/scorer.apk
Binary file not shown.
2 changes: 2 additions & 0 deletions Scorecounter/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
<activity android:name=".SaveResults.ResultActivity"></activity>
<activity
android:name=".LawnTennis.LawnTennisActivity"
android:label="Lawn Tennis"
android:screenOrientation="portrait" />
<activity
android:name=".AboutActivity"
android:label="About"
android:parentActivityName=".MainActivity" />
<activity
android:name=".Cricket.SelectFormat"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,104 +1,74 @@
package com.example.anmol.courtcounter;

import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.AdapterView;
import android.widget.ListView;

import com.example.anmol.courtcounter.Badminton.BadmintonActivity;
import com.example.anmol.courtcounter.Basketball.BasketballActivity;

import com.example.anmol.courtcounter.Cricket.SelectFormat;
import com.example.anmol.courtcounter.LawnTennis.LawnTennisActivity;
import com.example.anmol.courtcounter.SaveResults.ResultActivity;
import com.example.anmol.courtcounter.TableTennis.TableTennisAcitivity;

import com.example.anmol.courtcounter.Football.FootballActivity;
import com.example.anmol.courtcounter.Kabaddi.KabaddiActivity;
import com.example.anmol.courtcounter.Volleyball.VolleyballActivity;

public class MainActivity extends AppCompatActivity {
import java.util.ArrayList;

Button basketball;
Button volleyball;
Button badminton;
Button cricket;
Button tableTennis;
Button football;
Button kabaddi;
Button lawnTennis;
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
basketball = findViewById(R.id.button_basketball);
volleyball = findViewById(R.id.button_volleyball);
badminton = findViewById(R.id.button_badminton);
cricket = findViewById(R.id.button_cricket);
tableTennis =findViewById(R.id.button_tableTennis);
football = findViewById(R.id.button_football);
kabaddi = findViewById(R.id.button_kabaddi);
lawnTennis = findViewById(R.id.button_lawnTennis);


basketball.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
startActivity( new Intent( MainActivity.this, BasketballActivity.class ) );
}
} );

volleyball.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity( new Intent( MainActivity.this, com.example.anmol.courtcounter.Volleyball.VolleyballActivity.class ) );
}
} );
final ArrayList<menuItem> items = new ArrayList<menuItem>();
items.add(new menuItem(R.drawable.basketball, R.string.basketball));
items.add(new menuItem(R.drawable.volleyball, R.string.volleyball));
items.add(new menuItem(R.drawable.badminton, R.string.badminton));
items.add(new menuItem(R.drawable.tabletennis, R.string.tableTennis));
items.add(new menuItem(R.drawable.cricket, R.string.cricket));
items.add(new menuItem(R.drawable.football, R.string.football));
items.add(new menuItem(R.drawable.kabaddi, R.string.kabaddi));
items.add(new menuItem(R.drawable.tenn, R.string.tennis));

badminton.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity( new Intent( MainActivity.this, com.example.anmol.courtcounter.Badminton.BadmintonActivity.class ) );
}
} );
menuAdapter adapter = new menuAdapter(this, items);
ListView listView = (ListView) findViewById(R.id.list);
listView.setAdapter(adapter);

cricket.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity( new Intent( MainActivity.this, com.example.anmol.courtcounter.Cricket.SelectFormat.class ) );
}
} );
listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){

tableTennis.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity( new Intent( MainActivity.this, TableTennisAcitivity.class ) );
}
} );
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
menuItem item = items.get(position);

if(item.getTitle()==R.string.basketball)
startActivity(new Intent(MainActivity.this, BasketballActivity.class));
if(item.getTitle()==R.string.volleyball)
startActivity(new Intent(MainActivity.this, VolleyballActivity.class));
if(item.getTitle()==R.string.badminton)
startActivity(new Intent(MainActivity.this, BadmintonActivity.class));
if(item.getTitle()==R.string.tableTennis)
startActivity(new Intent(MainActivity.this, TableTennisAcitivity.class));
if(item.getTitle()==R.string.cricket)
startActivity(new Intent(MainActivity.this, SelectFormat.class));
if(item.getTitle()==R.string.football)
startActivity(new Intent(MainActivity.this, FootballActivity.class));
if(item.getTitle()==R.string.kabaddi)
startActivity(new Intent(MainActivity.this, KabaddiActivity.class));
if(item.getTitle()==R.string.tennis)
startActivity(new Intent(MainActivity.this, LawnTennisActivity.class));

football.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity( new Intent( MainActivity.this, FootballActivity.class ) );
}
} );

kabaddi.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity( new Intent( MainActivity.this, KabaddiActivity.class ) );
}
});

lawnTennis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, LawnTennisActivity.class));
}
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.example.anmol.courtcounter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.ArrayList;


public class menuAdapter extends ArrayAdapter<menuItem> {

public menuAdapter(Activity context, ArrayList<menuItem> item)
{
super(context,0, item);
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
{
View listItemView = convertView;
if(listItemView==null){
listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent,false);
}
menuItem currentItem = getItem(position);

TextView title_TextView = (TextView) listItemView.findViewById(R.id.title);
title_TextView.setText(currentItem.getTitle());

ImageView imageView = (ImageView) listItemView.findViewById(R.id.image);
imageView.setImageResource(currentItem.getImageResourceID());

return listItemView;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.anmol.courtcounter;

public class menuItem {
private int mImageResourceID;
private int title;

public menuItem (int ImageResourceID, int Title)
{
mImageResourceID = ImageResourceID;
title = Title;

}

public int getImageResourceID()
{
return mImageResourceID;
}
public int getTitle()
{
return title;
}
}
Loading