We have used Custom List View inside that one Text View and two Edit text present. I have put On Item CLick Listener On the Edit text Listener is set properly. What Is problem when fling action is happen then that listener is not setting. Is their any other Listener which can help me to control fling action.
may be you can't control the flying action, you can listen the flying action:
ListView.OnScrollListener can listen the scroll action:
#Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
#Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollState == OnScrollListener.SCROLL_STATE_FLING){ //flying
}
}
you can try this, hope it can help you -):
Related
I have problem with context menu when using android-swipelistview-sample from 47deg .(https://github.com/47deg/android-swipelistview). Problem is that when short click is made context menu is displayed .
How to show context menu just for long click ?
This bug is caused by curved touch event distribution in 47degrees swipe listview.
To fix this, just comment out
view.onTouchEvent(motionEvent);
in onTouch() method, in the end of switch case MotionEvent.ACTION_DOWN: in SwipeListViewTouchListener. Issue will go away, but scrolling your ListView will become dull, as soon, as your touch events will not be recognized while the listview is scrolling.
To overcome this problem, simply add to your SwipeListView class new flag, something like isScrolled.
Then, you need to update this flag each time, the scrolling state changes:
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
#Override
public void onScrollStateChanged(AbsListView absListView, int i) {
mListView.setScrolling(i == SCROLL_STATE_FLING);
}
#Override
public void onScroll(AbsListView absListView, int i, int i2, int i3) {
}
});
And finally, make it distribute touch event only when the view is scrolling:
if(swipeListView.isScrolling()){
view.onTouchEvent(motionEvent);
}
Good luck!
I think you were implementing the code on onItemLongClick, try creating context menu public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo)
where you will setup the menus.
Hope this helps you.
I'm using action bar pull to refresh of Chris Banes, and when I use the scroll listener to detect the bottom, it doesn't work.
#Override
public void onScrollStateChanged(AbsListView absListView, int i) {
Log.e("testing", "testing");
}
#Override
public void onScroll(AbsListView absListView, int i, int i2, int i3) {
Log.e("testing", "testing");
}
None of the methods are triggered.
Is there a way to use it? Or pull to refresh retain the listener for its use?
Done!
What I do was to enter this line
getListView().setOnScrollListener(this);
in onActivityCreated method. When I use it in others method, it was called just once.
I've implemented ListView in my application and working on onScrollListener. The ListView is working fine and in the onScroll() method of the onScrollListener, i'm trying to show a progressbar when the user has scrolled to the bottom.
The problem is that the listener doesn't stop listening and there are multiple progressbar loading on the screen if the user is trying to scroll even more. I don't have any idea how to solve this.
I want the onScrollListener to stop listening when the progressbar shows.
Please help
list.setOnScrollListener(new OnScrollListener() {
#Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
#Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (list.getLastVisiblePosition() == list.getAdapter().getCount() -
&& list.getChildAt(list.getChildCount() - 1).getBottom() <= list.getHeight()) {
ProgressBar pb = new ProgressBar(getActivity());
pb.setLayoutParams(pbParams);
linearLayout.addView(pb);
}
}
});
Thanks in advance
Can't you just check to see if there is already a progress bar and not add another?
I use Listview with Remote Control (Q1 Himedia SettopBOx)
Now down and up keydown ،How do I know where I am in listview
for example: when arrived in last item in listview then list refreshed or going to first item?
Please Help Me....
thanks
Take a look at OnScrollListener of ListView. You can set a new callback using ListView.setOnScrollListener() and get first visible item position and number of visible entries by implementing onScroll function of the listener.
Use an OnScrollListener for the listview like so.
myListView.setOnScrollListener(new OnScrollListener()
{
#Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount)
{
// Your code goes here. Determine the position with the firstVisibleItem.
}
#Override
public void onScrollStateChanged(AbsListView view, int scrollState)
{
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING)
{
Log.d(TAG, "User is flinging through the view");
}
}
});
I have an app that uses an ExpandableListView widget filled with items via a BaseExpandableListAdapter. The app was built for the Android Version 1.6, and when I test it using the Android Emulator (version 1.6 build) everything works fine. I can scroll the list up and down and when I tap on any items in the list I get a onChildClick() event.
However, when I try to run this same app on an real Android phone (running Gingerbread), I only get onChildClick() events if I don't scroll the ExpandableListView. If I scroll the list too much, I no longer get onChildClick events (nor itemClickEvents also).
So I'm baffled. Why do I not get any onChild or onItem click events for the listview items after I scroll it? Note, that if I scroll it just a small amount (say, 2 or three lines) I do get click events, but any more scrolling and then I no longer get click events for any item in the list.
Any suggestions or advice would be appreciated.
Thanks.
Ok, I'm answering my own question here for others who may have the same problem. The issue I'm experiencing seems to be related to the focus status of the ExpandableListView Widget. When I scroll the list, the ListView widget seems to lose focus and I can't select any of the listed items. I'm not sure what the best way is to correct this, but I did get this to work.
I added a scroll listener for the ListView widget as show:
getExpandableListView().setOnScrollListener(this);
I then added a method to my activity that would set the focus back to the ListView Widget once it is finished scrolling:
#Override
public void onScrollStateChanged(AbsListView view, int scrollState)
{
// - this method is called when there is a scroll event in the main ExpandableListView widget.
// - after the user stops scrolling the listview, make sure to set the focus to the widget
if ( scrollState == OnScrollListener.SCROLL_STATE_IDLE )
{
ExpandableListView elv = getExpandableListView();
elv.requestFocusFromTouch();
}
}
Now that seems to fix my issue. I'm sure there's a better way (and if you know of one, please post it here), otherwise my "hack" seems to work ok.
Hope it helps someone with a similar issue.
Thanks, this answer solved my problem on losing focus on while scrolling.
ListView mRecentSearchList;
mRecentSearchList.setOnScrollListener(new OnScrollListener(){
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
//adapter.notifyDataSetChanged();
}
public void onScrollStateChanged(AbsListView view, int scrollState) {
//adapter.notifyDataSetChanged();
if(scrollState == OnScrollListener.SCROLL_STATE_IDLE ||scrollState == SCROLL_STATE_TOUCH_SCROLL || scrollState == SCROLL_STATE_FLING)
{
mRecentSearchList.requestFocusFromTouch();
}
}
});
I have experienced exactly the same problem and I found that it was caused not by list itself but adapter(ResourceCursorTreeAdapter). To prevent groups to collapse I was doing a hack as follows in my adapter:
#Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View view = super.getGroupView(groupPosition, isExpanded, convertView, parent);
ExpandableListView list = (ExpandableListView) parent;
list.expandGroup(groupPosition);
return view;
}
If you do the same, please try replacing this with different solution.
In my case I've used the same solution proposed by cohoman, however the requestFocus() method provided me a better user experience:
navList.setOnScrollListener(new OnScrollListener()
{
#Override
public void onScrollStateChanged(AbsListView view, int scrollState)
{
if(scrollState == OnScrollListener.SCROLL_STATE_IDLE)
{
navList.requestFocus();
}
}
#Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
{
// TODO Auto-generated method stub
}
});