I want to have the SlidingDrawer show in 2 parts. On the first swipe up it shows only 1 button. and in the other swipe up, it shows the second button.
How can I do this? Thanks.
You could always have a counter in the SlidingDrawer that counts how many times the user have opened the drawer. And depending on the counter you either choose another layout or just use
setVisibility on different views.
Simple example, lets say you have button1 the first time the user opens the drawer and button2 the second time. If the user draws it a third time set the counter to 0 again.
if(counter==0) {
button1.setVisibility(View.VISIBLE);
button2.setVisibility(View.GONE);
}
else {
button1.setVisibility(View.GONE);
button2.setVisibility(View.VISIBLE);
}
SlidingDrawer
For the counter you could use setOnDrawerCloseListener to change the value since you want to have the upcoming counter value before the user have opened the drawer.
Related
I have a list view and two buttons(play & pause) I want that to when a play button touched a list view's first item go on top of page for example for 6 seconds and next item after first item be on top for 3 seconds and ...
This means Successively items go to top of list view's page and when I touch pause button it stop working and when I touch play button again it continue working
What can I do?
Sorry For my poor English
Sorry
you can keep a track of the last visible item on the screen like a counter. On click of play button increase the value of counter by 1 and set smooth scroll to the counter value. Do this inside a Timer object pass a TimerTask to create a new timer object and schedule it to run over and over again. Hope this helps.
http://developer.android.com/reference/java/util/Timer.html
http://developer.android.com/reference/java/util/TimerTask.html
I am working on a simple Android Activity which contain 10 images and 2 Buttons i.e. "Next" and "Previous", i changed all images by click on "next" and "Previous" Button using an array and both Buttons showing on every images but i want to don't show "Previous" button when user at first image and same as don't show "Next" button when user reached at tenth (last) image.
You have to use loop for this. When you on first activity make visibility of previous button hide. On last activity make next button invisible. You can make button invisible using-
btnName.setVisibility(View.INVISIBLE);
For making visible when you on second or second last image-
btnName.setVisibility(View.VISIBLE);
loop
{
if(i==0){
btnPrev.setVisibile(View.GONE);}
else
{
btnPrev.setVisibile(View.Visible)}
if(i==array.getSize()-1)
{
btnNext.setVisibile(View.GONE)};
else
{ btnNext.setVisibile(View.VISIBLE)}
I have implemented one "up" button and one "down" button in my layout.xml which I want to use in order to navigate through a ListView of strings. How can I accomplish this?
I do not want to use the "scroll" property of the ListView nor to use a LinearLayout with vertical orientation within a Scrollview in order to traverse the list. I simply want to move up and down my ListView by pressing the corresponding buttons.
Any help is appreciated!
You could have a variable int i = 0; in your class body.
Then when the activity loads, the item at location 0 would be selected. If your user presses the down button, then do:
i++;
setSelection(i);
And similarly for going back up:
i--;
setSelection(i);
Of course you'd have to add logic to the code for when you're already at selection 0 or at the maximum selection, but that's the gist of how I'd do it.
To note, I've never used ListView as I've not needed to, but the above should work. I got all my information from The Android Documentation
I have a page which contains a listview alone. Upon clicking a row in the list, the next page is loaded. This next page contains a set of buttons. Upon clicking a row in the list, the loading of the next page may take sometime. So if someone is continuously clicking the row then at some point of time, the second page comes and the buttons inside that gets clicked, which I dont require. How can I prevent this clicking of buttons? Can someone help me out. Thanks in advance.
Use AsyncTask concept to load data for next activity, do as follow:
set setEnabled(false) to all buttons inside the onPreExecute() method.
do all the background task inside the doInBackground() method.
and now again setEnabled(true) to all the buttons so that it become enabled and user can click on the buttons.
Besides the fact that your activities shouldn't take that long to load initially, you could just set a boolean when startActivity() is called to start the new activity. Then check that boolean if the user clicks anything else before the next activity is loaded.
if(document.readyState==complete) //NB this property is not supported by firefox
{
//Activate buttons
}
i think you need to false click event and true while you want to use
like this::
button1.setClickable(false);
and when you want to enable just write
button1.setClickable(true);
Activity1 has a listView. Clicking one item (let's say item 3) will start Activity2. Activity2 have a back button once clicked will bring user back to Activity1. What I want to achieve is to highlight the item 3 when user back to Activity1 so that the user have a sense where to continue. (May be i need to set the focus to item 3 as well.)
EDIT: Following code works.
public void onResume()
{
super.onResume();
//lastSelectedPosition saved in OnItemClickListener
lv.setSelection(lastSelectedPosition);
lv.requestFocusFromTouch();
}
well its pretty simple. just save the clicked item position of the list to a field when the list is clicked to launch your new activity.
Afterwards in the onResume() method just use myList.setSelection(savedPosition);
as for the highlighting, well focus works kinda bad especially if you have a bit more complex rows(buttons,checkboxes etc) and other ui elements beside the list that can take away the focus. i believe the best way to achieve this is just set the background of that particullar item onResume to the highlighted one and override onScroll listener to just change the background to your default when the list is scrolled. indeed its a workaround but it will work in 100% of the cases opposite to just focusing an item. plus maybe you can add animations on the view so you can make it look really nice and smooth.