Back to project page cellar-communicator.
The source code is released under:
GNU General Public License
If you think the Android project cellar-communicator listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.vinit.orderplacer; /*from www . j a v a 2 s.c o m*/ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.view.View; import android.view.View.OnClickListener; import android.widget.TextView; public class CounterOnClickListener implements OnClickListener { TextView tv, costs, total; boolean plus, is_summary; JSONArray jArr; int price, index; public CounterOnClickListener(TextView t, boolean b) { this.tv = t; this.plus = b; } public CounterOnClickListener(TextView t, boolean b, int price, TextView total) { this.tv = t; this.plus = b; this.price = price; this.total = total; } @Override public void onClick(View v) { int i = Integer.parseInt(tv.getText().toString()); i = (plus == true) ? i + 1 : i - 1; tv.setText(Integer.toString(i)); if(total != null) { int init = Integer.parseInt(total.getText().toString().substring(7)); init = (plus == true) ? init + price : init - price; total.setText("Total: " + Integer.toString(init)); } } }