【问题标题】:Calculate percentage of checked checkbox after press a button and show percentage in another activity (android)按下按钮后计算选中复选框的百分比并在另一个活动中显示百分比(android)
【发布时间】:2015-09-18 12:32:41
【问题描述】:

我在计算选中复选框的百分比时遇到问题。 我的情况是,我有复选框列表。用户按下任何复选框后,用户应按下计算按钮。此计算按钮将显示另一个活动并显示选中复选框的百分比。谁能帮我?

percentage = (checked/total checkbox)*100

【问题讨论】:

  • 查看此链接。它会解决你的问题。 stackoverflow.com/questions/17070082/…
  • 我已经尝试过了,但是当点击计算按钮时应用程序停止了......:
  • 你能提供同样的logcat吗
  • 在 com.example.sze.mutabaah.ChecklistActivity.percentageChecked(ChecklistActivity.java:170) 在 com.example.sze.mutabaah.ChecklistActivity$1.onClick(ChecklistActivity.java:62) 在 android。 view.View.performClick(View.java:4478) at android.view.View$PerformClick.run(View.java:18698) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler .dispatchMessage(Handler.java:95) 在 android.os.Looper.loop(Looper.java:149)
  • 你可以编辑你的答案而不是评论这么多代码

标签: java android checkbox


【解决方案1】:

在 Activity1 中,

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

在 Activity2 中,

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

【讨论】:

  • 计算kris ho怎么样?
猜你喜欢
  • 1970-01-01
  • 2017-03-03
  • 2020-02-18
  • 1970-01-01
  • 1970-01-01
  • 2019-02-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多