This is my activityresult1 where i display my listview
ArrayList<DataInfo> itemList, selectedList;
Button buttonorder;
TextView textviewemail;
private static final int REQUEST_CODE = 10;
//populate listview items
int[] image ={R.drawable.friednoodle, R.drawable.friedrice, R.drawable.steamfish,R.drawable.tehice};
String[] item = {"Fried Noodle", "Fried Rice", "Steam Fish","Iced Tea"};
String[] description = {"Classic Chinese stir fried noodle with prawn and Pork",
"Special sauce Fried Rice using indian rice", "HongKong Style Steamed Fish ","HongKong classical iced tea"};
String[] cost={"6","5","25","2"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activityresult1);
//bring the user's email keyed in from profileFragment
Bundle extras = getIntent().getExtras();
String tv_email = extras.getString("email");
getIntent().getExtras().getString("email");
textviewemail = (TextView) findViewById(R.id.textviewemail);
textviewemail.setText("Welcome, " + tv_email+ "" + "\nPlease select the food you want ! : ");
//show the listview items by taking the form of "List" layout
final MenuAdapter adapter = new MenuAdapter(this);
ListView listView = (ListView)findViewById(R.id.list);
listView.setAdapter(adapter);
//loop to show what is ordered
for (int i = 0; i < item.length; i++) {
adapter.addData(String.valueOf(i), item[i], image[i], description[i], cost[i]);
}
buttonorder = (Button) findViewById(R.id.suborder);
buttonorder.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String[] a = adapter.getQuantity();
Toast.makeText(getApplicationContext(), "Noodle: " + a[0] + "\nRice: " + a[1] +
"\nSteam fish: " + a[2] + "\nIced tea: " + a[3], Toast.LENGTH_LONG).show();
int sum = 0;
if (!adapter.getQuantity()[0].equals(""))
{
sum += Integer.parseInt(adapter.getQuantity()[0])*Integer.parseInt(cost[0]);
}
if (!adapter.getQuantity()[1].equals(""))
{
sum += Integer.parseInt(adapter.getQuantity()[1])*Integer.parseInt(cost[1]);
}
if (!adapter.getQuantity()[2].equals(""))
{
sum += Integer.parseInt(adapter.getQuantity()[2])*Integer.parseInt(cost[2]);
}
if (!adapter.getQuantity()[3].equals(""))
{
sum += Integer.parseInt(adapter.getQuantity()[3])*Integer.parseInt(cost[3]);
}
Intent intent = new Intent(getApplicationContext(), activityresult2.class);
Bundle bundle = new Bundle();
bundle.putString("Noodle quantity", adapter.getQuantity()[0]);
bundle.putString("Rice quantity", adapter.getQuantity()[1]);
bundle.putString("Fish quantity", adapter.getQuantity()[2]);
bundle.putString("Iced tea", adapter.getQuantity()[3]);
bundle.putInt("sum", sum);
bundle.putBoolean("ANI", adapter.getItem(0).isAddInisCheck());//add noodle ingredients
bundle.putBoolean("ARI", adapter.getItem(1).isAddInisCheck()); // add rice ingredients
bundle.putBoolean("AFI", adapter.getItem(2).isAddInisCheck());// add fish ingredients
bundle.putBoolean("AIT", adapter.getItem(3).isAddInisCheck()); // add ice tea ingredients
intent.putExtras(bundle);
startActivityForResult(intent, REQUEST_CODE);
}
});
}
this is the checkbox
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Ingredients $5"
android:id="@+id/addningc"
android:checked="false"
android:layout_below="@+id/description"
android:layout_toEndOf="@+id/fridenoodle" />
i want wondering if i can change one of the check box money and the text because all of the checkbox are the same now which is all add ingredients , for some i want to put add fish or *add rice** and some i dont want it to have a checkbox
Aucun commentaire:
Enregistrer un commentaire