himanshu-soni / quantityview Goto Github PK
View Code? Open in Web Editor NEWAndroid quantity view with add and remove button.
License: Apache License 2.0
Android quantity view with add and remove button.
License: Apache License 2.0
使用过程中,sync gradle 提示要求最低 SDK 版本为 15 ,实际上我手动导入 module ,14 也是可以的。
You need to use a Theme.AppCompat theme (or descendant) with this activity
When I use the component in my project, I have got this Error message!
So I have found the code and located the error at the following code:
else if (v == mTextViewQuantity) {
if (!quantityDialog) return;
if (mTextViewClickListener != null) {
mTextViewClickListener.onClick(v);
return;
}
// Crash at this line!
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(labelDialogTitle);
final View inflate = LayoutInflater.from(getContext()).inflate(R.layout.qv_dialog_changequantity, null, false);
final EditText et = (EditText) inflate.findViewById(R.id.qv_et_change_qty);
et.setText(String.valueOf(quantity));
builder.setView(inflate);
builder.setPositiveButton(labelPositiveButton, null);
final AlertDialog dialog = builder.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String newQuantity = et.getText().toString();
if (isValidNumber(newQuantity)) {
int intNewQuantity = Integer.parseInt(newQuantity);
Log.d(VIEW_LOG_TAG, "newQuantity " + intNewQuantity + " max " + maxQuantity);
if (intNewQuantity > maxQuantity) {
Toast.makeText(getContext(), "Maximum quantity allowed is " + maxQuantity, Toast.LENGTH_LONG).show();
} else if (intNewQuantity < minQuantity) {
Toast.makeText(getContext(), "Minimum quantity allowed is " + minQuantity, Toast.LENGTH_LONG).show();
} else {
setQuantity(intNewQuantity);
hideKeyboard(et);
dialog.dismiss();
}
} else {
Toast.makeText(getContext(), "Enter valid number", Toast.LENGTH_LONG).show();
}
}
});
}
getContext() should be replaced by getActivity(). Currently I have to note the code to solve this problem!
First, it's really thank you share this great component, it's beautiful. I use it in the shopping cart, the plus and minus button will call onQuantityChanged when user tap on it. But if the user edits the number through the EditText, it's won't call any listener, so kind of hard the tell the whole shopping cart the item has been changed.
I tried to reduce the size of the view but ,the + button gets hidden
<me.himanshusoni.quantityview.QuantityView
android:layout_marginEnd="10dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="100dp"
android:layout_height="35dp"
app:qv_quantity="1"
app:qv_minQuantity="1"
app:qv_quantityDialog="false" />
Hello @himanshu-soni ,
Can I give radius to quantity view?
I want Quantity view with corner radius
If you have added any such functionality , then please let me know.
Any help from your side will be greatly appreciated.
I am sending screen short on your gmail which will help you to understand problem.
Thank you!
How can get value of quantity when user changes the quantity?
I m aware that it has getOnQuantitChangeListener can help, but can you tell me how to use it?
setOnQuantityChangeListener call only when using left and right button but when i click on edit text in between and click on change after entering the amount to setOnQuantityChangeListener does not call.
在CoordinatorLayout > NestedScrollView > recyclerview这样的布局中,初始化后recyclerview中每个QuantityView点击正常,但滚动后就没法再点击了。
Default Text size is to small
it would be great if there's an attribute for orientation of the view, and allow us to determine if the "add" is on top or vise versa !
Also the rotation of "add" & "remove" drawables shouldn't be affected whether the view is vertical or horizontal !
控件设置了高度。加号和减号不能正常显示
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.