How to make ProgressBar undragable back? - android

I Have a ProgressBar which is being used to select a value from 0 to max, Now everything is working good, However sometimes i would like to limit the ProgressBar to not be able to scroll back.
The Bar is being used to select max players, later on the players are being chosen, and i want to block the abillity to set max players to lower then chosen players.
Meaning that if the bar is set to 6, at some condition i want to make it unscrollable back, but only forward.
I Don't want to change the minimum, cause that will change the bar.
How can i achive this?

You may inherit MyProgressBar from ProgressBar and override setProgress() with your own version, which will check if the new value is bigger than current or not.

Related

Is there any way to make long texts in android have a behaviour like the photo below (Read more button)?

is There any way in android to make some lines of the long text loose color ?
I'm giving you all the hints which you need to come up with solution rather than writing a solution
I'm assuming that your text is dynamic in nature that means text length will vary.
First of all, you will have a constant defined in your class which provides max line count to show initially (along with read more) button
// here for example, you want to show 5 lines along with read more button
private static final int DEFAULT_DESCRIPTION_LINES_PORTRAIT = 5;
Now, as soon as you set your text, you check whether your text's line count is less than 5 or not. If it's less than 5 then you don't need to show read more button at all. If it's more than 5 then you would set maxLines of that TextView to your default lines. Also you'll make read more button visible
textView.setMaxLines(DEFAULT_DESCRIPTION_LINES_PORTRAIT);
readMorebutton.setVisibility(View.VISIBLE);
Now, you'll simply toggle maxLines to either default or actual line count whenever user presses on that button. Along with that make readMoreButton visibility gone to visible respectively.
Also it might be possible that TextView layout inflation takes time, so you might want to run a runnable on post of that TextView so that you're sure whenever you call textivew..getLineCount(); then you'll get correct value.
Regarding that gradient on top of button, you may simply have that button along with full width view on top of it (which would have a gradient background) in a vertical LinearLayout.
I hope this helps.

Android - Create a settings object similar to volume control

As the title says, I was wondering if there is a way to add a way to create input in my Android application, by providing the user with a bar similar to the one used by Android system for adjusting the sound volume. A specific variable would change its value, according to the position of a "button" on the bar (sorry for my English). Any advice on that?
A SeekBar is what you are looking for.
Here is the design spec: https://www.google.com/design/spec/components/sliders.html#
Here is the reference page: http://developer.android.com/reference/android/widget/SeekBar.html
If you want to set the value of the position of the SeekBar, simply do:
seekBar.setProgress(position);
where position is where you want the SeekBar to be.
Getting the position of the SeekBar is a bit more involved. Firstly you must set a setOnSeekBarChangeListener and grab the SeekBar value from within the onProgressChanged method. This is a StackOverflow question that answers this well: get android seekbar value and display it on screen

Android Hide TimePicker numbers?

Is there a way to hide these numbers? Im guessing there must be an attribute which once set to 'false' should to it.
Also, i've tried to use custom drawables for the the up/down arrow, but those seem to overlay on top of the numbers (ie,the numbers are still visible)
Note: I could make custom pickers where I use a textView in between two imageViews, but the default timePicker allows one to swipe up and scroll through numbers (so would prefer using the default)
Edit: Apparently the NumberPicker has different children in different versions of android(the emulator shows the up/bottom arrows, while on my Samsung Tab they return a nullpointerexception). Wow!
Instead of using a time picker you could try and use a number picker instead, this means that you can specifically set what you want to be in the picker.
Is there a way to hide these numbers?
No, sorry.
Im guessing there must be an attribute which once set to 'false' should to it.
Only if you fork TimePicker and add such an attribute yourself.

Using progress bar to show how much account space is left

I am trying to use a progress bar to show how much of my income account is left.
E.g , i have a limit of say 1000$ stored in my account named as limit. Now i want to set the progress bar so that it will show how much of this amount is left. Lets say i have used 200$ and now remaining is 800$. How can i show that in progress bar.
I have tried to use progressbar.setposition but can't find a way to achieve above thing.
Best Regards
Use the below line::
progressBar.setProgress(int);
Define the total value, then set the current progress:
progressBar.setMax(myTotalAmount)
progressBar.setProgress(myConsumedAmount)

Am I thinking of a ProgressBar or something else? Android

I am new to Android/Java/Programming...
I am not sure if I am researching the correct term, but I am looking to have a horizontal bar on my application with no animation. The bar will show a static number from x to y based on a selected button from the user.
Can a ProgressBar be used as a standalone graphic like a bar graph? What is the correct term for me to research?
Edited to add…
Can I remove the user functionality from being able to adjust the seekbar?
The progress bar is used to show progress of some operation and it used the concept of threading.
In your case I think you are talking about seekbar ,.. the value of seekbar can be changed in the application through appropriate controls..e.g onbuttonpress or editing value in textbox
hi what you are looking for is actually a seek bar...
Go through this for a sample
I think you are looking for SeekBar.
A SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch the thumb and drag left or right to set the current progress level or use the arrow keys.
For more details go through these links: link1 & link2
Hope this will solve your issue.

Categories

Resources