Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
restaurant-ordering-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cs123-ros
restaurant-ordering-system
Commits
20f16f70
Commit
20f16f70
authored
Dec 03, 2015
by
Jino Basilio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented working methods for listView
parent
68c7e7e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
17 deletions
+38
-17
Kitchen.java
...2/src/com/cs123grpE/restaurantorderingsystem/Kitchen.java
+38
-17
No files found.
RestaurantOrderingSystem2/src/com/cs123grpE/restaurantorderingsystem/Kitchen.java
View file @
20f16f70
package
com
.
cs123grpE
.
restaurantorderingsystem
;
package
com
.
cs123grpE
.
restaurantorderingsystem
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -8,14 +8,20 @@ import android.content.res.Resources;
...
@@ -8,14 +8,20 @@ import android.content.res.Resources;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.Menu
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView.OnItemClickListener
;
import
android.widget.ArrayAdapter
;
import
android.widget.ListView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
public
class
Kitchen
extends
Activity
{
public
class
Kitchen
extends
Activity
{
ListView
lv
;
ListView
lv
;
KitchenAdapter
adapter
;
//
KitchenAdapter adapter;
public
Kitchen
CustomListView
=
null
;
//public Kitchen CustomListView = this
;
public
ArrayList
<
OrderModel
>
CustomListViewValuesArr
=
new
ArrayList
<
OrderModel
>();
public
ArrayList
<
OrderModel
>
CustomListViewValuesArr
=
new
ArrayList
<
OrderModel
>();
@Override
@Override
...
@@ -23,17 +29,39 @@ public class Kitchen extends Activity {
...
@@ -23,17 +29,39 @@ public class Kitchen extends Activity {
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_kitchen
);
setContentView
(
R
.
layout
.
activity_kitchen
);
CustomListView
=
this
;
/******** Take some data in Arraylist ( CustomListViewValuesArr ) ***********/
/******** Take some data in Arraylist ( CustomListViewValuesArr ) ***********/
setListData
();
setListData
();
//Resources res = getResources();
Resources
res
=
getResources
();
lv
=
(
ListView
)
findViewById
(
R
.
id
.
listKitchen
);
lv
=
(
ListView
)
findViewById
(
R
.
id
.
list
);
// List defined in XML ( See Below )
/**************** Create Custom Adapter *********/
/**************** Create Custom Adapter *********/
adapter
=
new
KitchenAdapter
(
CustomListView
,
CustomListViewValuesArr
,
res
);
// adapter=new KitchenAdapter( CustomListView, CustomListViewValuesArr,res );
lv
.
setAdapter
(
adapter
);
//lv.setAdapter( new ArrayAdapter<OrderModel>(this, R.layout.menu_item, R.id.foodName, CustomListViewValuesArr));
@SuppressWarnings
(
"unchecked"
)
final
ArrayAdapter
<
OrderModel
>
adapter
=
new
ArrayAdapter
(
getBaseContext
(),
android
.
R
.
layout
.
simple_list_item_2
,
android
.
R
.
id
.
text1
,
CustomListViewValuesArr
)
{
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
View
view
=
super
.
getView
(
position
,
convertView
,
parent
);
TextView
text1
=
(
TextView
)
view
.
findViewById
(
android
.
R
.
id
.
text1
);
TextView
text2
=
(
TextView
)
view
.
findViewById
(
android
.
R
.
id
.
text2
);
text1
.
setText
(
CustomListViewValuesArr
.
get
(
position
).
getFoodName
());
text2
.
setText
(
CustomListViewValuesArr
.
get
(
position
).
getTableNumber
());
return
view
;
}
};
lv
.
setAdapter
(
adapter
);
lv
.
setOnItemClickListener
(
new
OnItemClickListener
()
{
@Override
public
void
onItemClick
(
AdapterView
<?>
arg0
,
View
arg1
,
int
arg2
,
long
arg3
)
{
CustomListViewValuesArr
.
remove
(
arg2
);
adapter
.
notifyDataSetChanged
();
}
});
// adapter.notifyDataSetChanged();
}
}
@Override
@Override
...
@@ -62,7 +90,6 @@ public class Kitchen extends Activity {
...
@@ -62,7 +90,6 @@ public class Kitchen extends Activity {
public
void
setListData
()
public
void
setListData
()
{
{
for
(
int
i
=
0
;
i
<
11
;
i
++)
{
for
(
int
i
=
0
;
i
<
11
;
i
++)
{
final
OrderModel
sched
=
new
OrderModel
();
final
OrderModel
sched
=
new
OrderModel
();
...
@@ -74,11 +101,5 @@ public class Kitchen extends Activity {
...
@@ -74,11 +101,5 @@ public class Kitchen extends Activity {
/******** Take Model Object in ArrayList **********/
/******** Take Model Object in ArrayList **********/
CustomListViewValuesArr
.
add
(
sched
);
CustomListViewValuesArr
.
add
(
sched
);
}
}
}
}
public
void
onItemClick
(
int
mPosition
)
}
{
CustomListViewValuesArr
.
remove
(
mPosition
);
adapter
.
notifyDataSetChanged
();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment