1.android Studio Import Open Source project source code should pay attention to the conflict with their own package, such as you have a com.xxxx package, and need to import the com.xx.yy you can not copy the entire package, otherwise will be reported can ' t resolve Symbil ...
Because it is based on COM will go to your original package to find the relevant class. So when the test just put xx.yy test of your original COM directory can.
2. Get the screen width: the first type:
/** * Gets the high-size pixels of the screen px * * @param Activity * @return int * /public static int Getscreenheight ( Activity cont) { displaymetrics dm = new Displaymetrics (); Gets the window Properties cont.getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); The height of the window return dm.heightpixels; }
The second type:
/** * Context * @param context * @return * /public static int Get_height_bycontext (context context ) { displaymetrics dm = new Displaymetrics (); WindowManager wm = (WindowManager) context . Getsystemservice (context.window_service); (Wm.getdefaultdisplay ()). Getmetrics (DM); int height = dm.heightpixels; return height; }
3. Nesting the ListView in the ListView because the inside of the ListView height is not sure, even if set to match the parent display is only a bit, so to rewrite the inside of the ListView onmeasure
@Overrideprotected void onmeasure (int widthmeasurespec, int heightmeasurespec) { int expandspec = Measurespec.makemeasurespec (Integer.max_value >> 2, measurespec.at_most); Super.onmeasure (Widthmeasurespec, <span style= "font-family:arial, Helvetica, Sans-serif;" >expandSpec</span>);}
But this will be all displayed, the inside of the ListView can not slide, so we in the inside of the ListView and then set a layer of linearlayout layout, set a default height, in the code to get the screen height again set, so that although not fully displayed but still does not slide:
You can only release the events from the outside of the ListView and let the time pass to the child controls:
@Override Public Boolean onintercepttouchevent (motionevent ev) { return false; }
So the ListView can slide, but the outside of the slide is not ... The workaround is to modify the interception method above: Add ignore view only click on the specified view to block: like this:
/** * Returns whether the area of our touch is a view that returns the view otherwise returns null * * @param ignoreviews * @param ev * @return */ private View Gettouchignoredview (list<view> ignoreviews, motionevent ev) { if (ignoreviews = null | | ig Noreviews.size () = = 0) { return null; } Rect mrect = new rect (); for (View v:ignoreviews) { v.gethitrect (mrect); if (mrect.contains (int) ev.getx (), (int) ev.gety ())) { return v; } } return null; }
/** * event blocker */ @Override public boolean ONINTERCEPTT Ouchevent (motionevent ev) { //handling Viewpager conflict issues Viewpager Mviewpager = Gettouchviewpager (mviewpagers, Ev); View Ignoredview = Gettouchignoredview (ignoredviews, Ev) ; if (ignoredview! = null) { return SUPER.ONINTERCEPTT Ouchevent (EV); } if (Mviewpager! = null && mviewpager.getcur Rentitem ()! = 0) { return super.onintercepttouchevent (EV); &N Bsp } if (allowslide_flage) { switch (ev.getaction ()) {&NB Sp case motionevent.action_down: &N Bsp DOWNX = TEMPX = (int) ev.getrawx (); DownY = ( int) Ev.getrawy (); break; case motionevent.action_move: &N Bsp int moveX = (int) ev.getrawx (); //meet this condition mask Sildingfini Shlayout inside sub-category touch events if (Movex-downx > Mtouchslo p && Math.Abs (in T) Ev.getrawy ()-DownY) < Mtouchslop) { &N Bsp Return true; } &NBS P &NBSP break; } } RE Turn super.onintercepttouchevent (EV); }
Summary of Project issues