我# Formula for mortgage calculator
# M = L(I(1 + I)**N) / ((1 + I)**N - 1)
# M = Monthly Payment, L = Loan, I = Interest, N = Number of payments, ** = exponent
# Declares and asks for user to input loan amount. Then converts to float
loanAmount = input('Enter loan amount \n')
loanAmount = float(loanAmount)
# Declares and asks user to input number of payments in years. Then converts to float. Years * 12 to get
# total number of months
years = input('How many years will you have the loan? \n')
years = float(years) * 12
# Declares and asks user to input interest rate. Then converts to float and input interest rate is /100/12
interestRate = input('Enter Interest Rate \n')
interestRate = float(interestRate) / 100 / 12
# Formula to calculate monthly payments
mortgagePayment = loanAmount * (interestRate * (1 + interestRate)
** years) / ((1 + interestRate) ** years - 1)
# Prints monthly payment on next line and reformat the string to a float using 2 decimal places
print("The monthly mortgage payment is\n (%.2f) " % mortgagePayment)
上有Recylerview
。我可以使用以下代码禁用recylerview项目选择
Activity
但我希望以下功能显示禁用/启用外观
启用RV:
关闭,禁用 recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
// true: consume touch event
// false: dispatch touch event
return touch;
}
});
中的全部或部分项目,如下所示
我猜它对于`RecyclerView'有点透明。因为项目仍然可以点击,因为我可以看到项目点击的涟漪效应,但功能在禁用时不起作用。如何在我的应用程序中实现此行为
答案 0 :(得分:1)
从上面的代码中禁用recyclerview后,更改每行的不透明度和每个行项的setEnable(False),同时启用recyclerview删除不透明度和setEnable(true)。
在toogle按钮的changelistner中,使用不透明度和所有内容的更改刷新recyclerview。
为您提供信息我正在添加一个简单的代码: -
toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b){
tvText.setEnabled(true);
tvText.setText("enabled");
tvText.setAlpha(1);
}else{
tvText.setText("disabled");
tvText.setAlpha(0.4f);
tvText.setEnabled(false);
}
}
});
从if else循环刷新recyclelerview并将启用/禁用值传递给它并更改每行的alpha。
答案 1 :(得分:0)
只需在Recycler视图上添加透明视图,并将xml中的 android:clickable =“true”设置为前景视图。