【发布时间】:2020-11-15 14:57:33
【问题描述】:
我制作了一个基本的存款金额计算应用程序,用户可以在其中输入金额和期限(以月为单位),然后点击计算按钮,然后应用程序应该向用户显示利息值。如果我使用下面的代码在 android studio 构建这个项目。应用程序在设备上安装并打开,但单击按钮时,应用程序将自动关闭。我不明白故障是出在下面的代码还是设备上。
EditText et1,et2;
TextView mv,ie;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=(EditText)findViewById(R.id.et1);
et2=(EditText)findViewById(R.id.et2);
mv=(TextView)findViewById(R.id.mv);
ie=(TextView)findViewById(R.id.ie);
}
public void Cumlative(View v){
float depositamt = Integer.parseInt(et1.getText().toString());
float tenure = Integer.parseInt(et2.getText().toString());
float matval = (float)((depositamt*tenure)/100);
ie.setText((int) matval);
}
下面是xml文件
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Deposit Amount"
android:id="@+id/et1"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Tenure in Months"
android:id="@+id/et2"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cumlative"
android:textStyle="bold"
android:textColor="#8BC34A"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Maturity value"
android:id="@+id/mv"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Intrest earned"
android:id="@+id/ie"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calculate"
android:layout_gravity="center"
android:id="@+id/cal"
android:onClick="Cumlative"/>
日志:
11-15 20:59:08.102 15074-15074/? I/fpc_tac: Returning from transfer command 0x24;3028
11-15 20:59:08.102 15074-15074/? I/fpc_tac: <--_fpc_tac_transfer_data returns tlTci->rsp.cmd_ret;3040
11-15 20:59:08.102 15074-15074/? I/fpc_tac: Enter _fpc_tac_load_database_id;2325
11-15 20:59:08.102 15074-15074/? I/fpc_tac: _fpc_tac_load_database_id, random_id_size, 96;2349
11-15 20:59:08.102 15074-15074/? I/fpc_tac: -->_fpc_tac_transfer_data command 0x29;2866
11-15 20:59:08.102 15074-15074/? I/fpc_tac: -->_fpc_tac_send_cmd command 0x02,0x29;2677
【问题讨论】:
-
请提供来自 logcat 的日志。
-
11-15 20:59:08.102 15074-15074/? I/fpc_tac:从传输命令返回 0x24;3028 11-15 20:59:08.102 15074-15074/? I/fpc_tac: rsp.cmd_ret;3040 11-15 20:59:08.102 15074-15074/? I/fpc_tac:输入_fpc_tac_load_database_id;2325 11-15 20:59:08.102 15074-15074/? I/fpc_tac: _fpc_tac_load_database_id, random_id_size, 96;2349 11-15 20:59:08.102 15074-15074/? I/fpc_tac: -->_fpc_tac_transfer_data 命令 0x29;2866 11-15 20:59:08.102 15074-15074/? I/fpc_tac: -->_fpc_tac_send_cmd命令0x02,0x29;2677
-
上面的xml和java代码可以吗?我应该提供来自 logcat 的哪一部分日志
标签: android mobile-application calculation