Kamis, 30 April 2015

How to solve the ListView scrolling problem inside ScrollView as a parent in Android Java

How to solve the ListView scrolling problem inside ScrollView as a parent in Android Java - First announced in March 2017, the Xperia L1 has come to replace Sony’s now discontinued E series. Priced at a surprisingly cheap £169, the L1 is Sony’s newest attempt at shaking up the budget phone market. Its large screen and sleek design make us think of Sony’s higher range of smartphones: it would be hard to single it out as the cheapest model in a line of Xperias. But at such a bargain price, we can’t expect it to perform as well as its more expensive counterparts. So how does the L1 hold up to other low-budget smartphones? Here’s our Xperia L1 review. first time the View branding, well we have collected a lot of data from the field directly and from many other blogs so very complete his discussion here about How to solve the ListView scrolling problem inside ScrollView as a parent in Android Java, on this blog we also have to provide the latest automotive information from all the brands associated with the automobile. ok please continue reading:

Hi there,

Now iam going to give you a solution for "How to solve the ListView scrolling problem inside ScrollView as a parent in Android Java".

Introduction
Most of us we developers,facing problems while adding a ListView into a layout inside a ScrollView because of the screen size the items of the layout may overflow,so what we developers must want to use a ScrollView for solving that overflow problem.But there comes the problem what happense when we put a ListView as an item into the ScrollView.Due to multiple scrollable items in a single screen,the android os confused to handle the scroll event for which item the ListView or ScrollView,atlast it will give scroll event to ScrollView as it is the top most view considering the ListView.



How to get the touch event to ListView?
Don't feel overloaded it is simple to get all the things done.

  • Only one thing we want to do is just initialize a custom TouchListener for the ListView.
  • Initialize the ListView 

ListView itemsList=(ListView)findViewById(R.id.listItemsSale);

  •  Now simply add a TouchListener to the ListView.
itemsList.setOnTouchListener(new OnTouchListener() {
   // Setting on Touch Listener for handling the touch inside ScrollView
   @Override
   public boolean onTouch(View v, MotionEvent event) {
   // Disallow the touch request for parent scroll on touch of child view
   v.getParent().requestDisallowInterceptTouchEvent(true);
   return false;
   }
});

Conclusion
Feel free to use the above code anywhere you want.Any new ideas or helps feel free to use the comment box. 

Tidak ada komentar:

Posting Komentar