简体   繁体   English

按下按钮后计算已选中复选框的百分比,并在另一个活动中显示百分比(android)

[英]Calculate percentage of checked checkbox after press a button and show percentage in another activity (android)

I have a problem towards of calculating percentage of checked checkbox. 我对计算已选中复选框的百分比有疑问。 My situation is, i have list of checkbox. 我的情况是,我有复选框列表。 after user press any checkbox, user should press calculate button. 用户按下任何复选框后,应按下“计算”按钮。 this calculate button will show another activity and also display percentage of checked checkbox. 此计算按钮将显示另一个活动,并显示已选中复选框的百分比。 Can anyone help me? 谁能帮我?

percentage = (checked/total checkbox)*100

In Activity1, 在活动1中,

Intent i = new Intent(getApplicationContext(), activity2.class);
i.putExtra("key", chkbox1.getText()); //pass chkbox1 value to another activity
startActivity(i);

In Activity2, 在活动2中,

String chkbox1=getIntent().getExtras().getString("key");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM