计算总量
回答
我已经解决了这个您只要致电从 父方法customadapter其执行你的总计算
喜欢这个((ParentClass) context).TotalCalculationfunctionToRun();
从加号或减号按钮分别单击
谢谢你abhishek – 2014-11-01 12:21:28
尝试这样可以帮助你,
private int getTotal(){
private int totalamount = 0;
for(int i = 1; i < list.getCount(); i++){
View view = list.getAdapter().getView(i, null, list);
TextView txt = (TextView) view.findViewById(R.id.yourid);
int amount = Integer.paserInt(txt.getText().toString())
totalamount += amount;
}
return totalamount;
}
但它如何帮助更新总在点击的时候加或减号 – 2014-10-31 11:29:36
点击该按钮 – 2014-10-31 11:30:26
该按钮是在列表视图内 – 2014-10-31 11:31:04
我有一个解决方案的自定义适配器,可能是它可以让你帮助
<TextView
android:id="@+id/cartTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="RS 0.00"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/cartTotal"
android:text="Total: "
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/textView2" />`
给定屏幕的适配器的设计布局
<TextView
android:id="@+id/tiem_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:text="TextView"
android:textSize="20dp" />
<TextView
android:id="@+id/flag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:text="TextView"
android:textSize="20dp" />
<TextView
android:id="@+id/eachPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:text="120.0"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/ext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:text="Index Total Price"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="20dp"
android:orientation="horizontal">
<EditText
android:id="@+id/editText2"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="28dp"
android:hint="Qty" />
<Button
android:id="@+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/minus"
android:layout_alignBottom="@+id/minus"
android:layout_marginEnd="18dp"
android:layout_marginRight="18dp"
android:layout_toLeftOf="@+id/minus"
android:layout_toStartOf="@+id/minus"
android:text="+" />
<Button
android:id="@+id/minus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText2"
android:layout_alignBottom="@+id/editText2"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="-" />
</RelativeLayout>
模型项
public class CartItem {
String name;
String flag;
int UserQty;
double ProductPrice;
double ProductSalePrice;
private Double ext = 0.00;
public Double getExt() {
return ext;
}
public void setExt(Double ext) {
this.ext = ext;
}
public double getProductSalePrice() {
return ProductSalePrice;
}
public void setProductSalePrice(double productSalePrice) {
ProductSalePrice = productSalePrice;
}
public double getProductPrice() {
return ProductPrice;
}
public void setProductPrice(double productPrice) {
ProductPrice = productPrice;
}
public int getUserQty() {
return UserQty;
}
public void setUserQty(int userQty) {
UserQty = userQty;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
}
**Main Activity**
公共类MainActivity延伸活动{ 字符串URL = “http://139.59.43.252/cnsgoCash/api/ws/controller/?access=true&action=get_category_by_product_list&id=5”; ProgressDialog PD; 按钮付款;
private ExpandListAdapter ExpAdapter;
private ExpandableListView ExpandList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
payment=(Button)findViewById(R.id.payment);
ExpandList = (ExpandableListView) findViewById(R.id.expandableListView);
PD = new ProgressDialog(this);
PD.setMessage("Loading.....");
PD.setCancelable(false);
makejsonobjreq();
/* Click*/
payment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent in =new Intent(MainActivity.this,AddedItemActivity.class);
startActivity(in);
}
});
ExpandList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
}
});
}
private void makejsonobjreq() {
PD.show();
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
System.out.println("Json String :" + String.valueOf(response));
Log.e("RES", String.valueOf(response));
ArrayList<Group> list = new ArrayList<Group>();
ArrayList<Child> ch_list;
try {
//Iterator<String> key = response.keys();
JSONArray jsonArray=response.getJSONArray("data");
for(int i=0;i<jsonArray.length();i++){
JSONObject object= jsonArray.getJSONObject(i) ;
String k = object.getString("categoryName");
Log.e("Parent","hello"+k);
Group gru = new Group();
gru.setName(k);
ch_list = new ArrayList<Child>();
JSONArray ja = object.getJSONArray("productdetails");
for (int j = 0; j < ja.length(); j++) {
JSONObject jo = ja.getJSONObject(j);
Child ch = new Child();
//Log.e("Child","hello"+jo.getString("productName"));
ch.setName(jo.getString("productCode"));
ch.setFlag(jo.getString("productName"));
ch.setUserQty(jo.getString("quantity"));
ch.setProductPrice(jo.getString("sellPrice"));
ch_list.add(ch);
} // child for loop end
gru.setItems(ch_list);
list.add(gru);
}
ExpAdapter = new ExpandListAdapter(MainActivity.this, list);
ExpandList.setAdapter(ExpAdapter);
PD.dismiss();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(jsonObjectRequest);
}
}
- 1. 计算总量
- 2. 计算总能量
- 3. 计算变量的总和
- 4. JS计算总变化量
- 5. 计算总变量总和的问题
- 6. 计算总计
- 7. 计算总计
- 8. 根据计量单位和计算总和计算
- 9. 计算总计值
- 10. WooCommerce计算总计
- 11. 计算行明智总计和总计
- 12. 总计差额并计算总计
- 13. 计算总和
- 14. 计算总和
- 15. 计算总和
- 16. 计算总和
- 17. 计算总和
- 18. 计算总数
- 19. 计算总排
- 20. 总数计算
- 21. 计算总价
- 22. 从小计计算总计
- 23. 如何计算每日总量?
- 24. 总数量与jQuery计算插件
- 25. 计算两个变量的总和
- 26. 如何计算运行总量?
- 27. 如何计算电池的总容量
- 28. Yii框架....计算飞行总量
- 29. Vue 2 - 计算行的总输入量
- 30. 矢量的代码来计算总和
请向我们提供您的代码块你尝试过什么,你面临 – Pratik 2014-10-31 11:24:25
问题我所做的是什么,我都要求从定制适配器上的加号按钮点击,但它的功能更新时,活动从午餐切换到早餐,我想在点击@ PRATIK – 2014-10-31 11:27:03
的时间来更新@Pratik请给一些想法,以更新 – 2014-10-31 11:57:34