android繼承View,onDraw方法實現首字母快速定位

來源:互聯網
上載者:User

  SideBar   textColor = 0xFFA6A9AA  backgroundColor = 0x55DDDDDD  backgroundActionDownColor = 0xFFCCCCCC  isDown =  SideBar(Context context, AttributeSet attrs,  [] l =  [0 SectionIndexer sectionIndexter =   m_nItemHeight = 29     selectIndex = -1  ==  onMeasure( widthMeasureSpec, .textSize = height = width =.selfHeight =.selfWidth == selfHeight / newWidth = MeasureSpec.makeMeasureSpec(() .textSize + 5  i = ( idx = i / (idx >== l.length - 1  (idx < 0= 0 (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == (sectionIndexter == = position = (position == -1 .selectIndex ==  (event.getAction() === .selectIndex = -1 "DrawAllocation" = = textHeight = () (Math.ceil(fm.descent - fm.ascent) + 2 widthCenter = getMeasuredWidth() / 2= = =  RectF(0, 0=  RectF(0, 015, 15 ( i = 0; i < l.length; i++ (selectIndex === 0xffccffcc=  RectF(0, i * m_nItemHeight, getWidth(), m_nItemHeight + i *15, 15  (selectIndex == l.length - 1= 0xffccffcc=  RectF(0, l.length *15, 15

              float offsetY=((i)*m_nItemHeight)+((m_nItemHeight-textHeight)/2+textHeight-8);//字型縱向置中,20130530修正更新

              canvas.drawText(String.valueOf(l[i]), widthCenter, offsetY, paint);

  setSections(.l =
 <String> indexs =  ArrayList<String>      addIndex(   indexAt( String get( 
  MyAdapter  BaseAdapter  ArrayList<String> MyAdapter(Context _context, ArrayList<String>===""= c = frist.charAt(0=(!+=0  Object getItem(  getItemId( 0 View getView(== (View) inflate.inflate(R.layout.listview_row, == currentF=stringArray.get(position).charAt(0(position==0""+ oldF=stringArray.get(position-1).charAt(0(!(""+currentF).equalsIgnoreCase((""+""+""  getPositionForSection( position=indexs.indexAt((  getSectionForPosition( 0 
  MainActivity  ==<String> stringList ==  MyAdapter( ArrayList<String><String> stringList =  ArrayList<String>"asdf""anbcd""bdcd""bfefasf""bcadaf""csdafad""dfdaf""edfdfd""fsdfadfasfd""fadsfasdf""fweff""fhghdfgh""gasdfasdfsa""gadfawe""haof""hjooiuoiuio""iasdfasdfas""zero""zoo""zeus""zebra""zest""zing"

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.