-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5b475e
commit 69188e9
Showing
5 changed files
with
49 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 30 additions & 4 deletions
34
app/src/main/java/com/mtb/foodorderreview/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,48 @@ | ||
package com.mtb.foodorderreview; | ||
|
||
import android.os.Bundle; | ||
import android.widget.LinearLayout; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
import android.widget.GridView; | ||
import android.widget.Toast; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import java.util.Arrays; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
HomeFoodTypeUI(); | ||
} | ||
|
||
private void HomeFoodTypeUI() { | ||
HomeFoodType rice = new HomeFoodType("Rice", R.drawable.icon_food_type_rice); | ||
HomeFoodType rice2 = new HomeFoodType("Rice2", R.drawable.icon_food_type_rice); | ||
HomeFoodType rice3 = new HomeFoodType("Rice3", R.drawable.icon_food_type_rice); | ||
HomeFoodType rice4 = new HomeFoodType("Rice4", R.drawable.icon_food_type_rice); | ||
HomeFoodType rice5 = new HomeFoodType("Rice5", R.drawable.icon_food_type_rice); | ||
|
||
HomeFoodType[] l = {rice, rice2, rice3, rice4, rice5}; | ||
|
||
HomeFoodTypeGridAdapter adapter = new HomeFoodTypeGridAdapter(this, Arrays.asList(l)); | ||
|
||
GridView gridView = findViewById(R.id.home_food_type_grid_1); | ||
gridView.setAdapter(adapter); | ||
|
||
Toast.makeText(this, "Hihi", Toast.LENGTH_SHORT).show(); | ||
|
||
LinearLayout layout = findViewById(R.id.LinearLayout1); | ||
layout.setOnClickListener(v -> { | ||
Toast.makeText(this, "Hhihi", Toast.LENGTH_SHORT).show(); | ||
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | ||
@Override | ||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | ||
Object o = gridView.getItemAtPosition(position); | ||
HomeFoodType foodType = (HomeFoodType) o; | ||
Toast.makeText(MainActivity.this, "Selected :" + " " + foodType.getName(), Toast.LENGTH_LONG).show(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/grey_1" /> | ||
<corners android:radius="4sp" /> | ||
<solid android:color="@color/white" /> | ||
<corners android:radius="12sp" /> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters