if (this.mAreHeadersSticky != areHeadersSticky) {
this.mAreHeadersSticky = areHeadersSticky;
requestLayout();
}
}
public boolean getAreHeadersSticky() {
return mAreHeadersSticky;
}
@Override
public void setAdapter(ListAdapter adapter) {
if (this.isInEditMode()) {
super.setAdapter(adapter);
return;
}
if (adapter == null) {
mAdapter = null;
reset();
super.setAdapter(null);
return;
}
if (!(adapter instanceof StickyListHeadersAdapter)) {
throw new IllegalArgumentException(
“Adapter must implement StickyListHeadersAdapter”);
}
mAdapter = wrapAdapter(adapter);
reset();
super.setAdapter(this.mAdapter);
}
private AdapterWrapper wrapAdapter(ListAdapter adapter) {
AdapterWrapper wrapper;
if (adapter instanceof SectionIndexer) {
wrapper = new SectionIndexerAdapterWrapper(getContext(),
(StickyListHeadersAdapter) adapter);
} else {
wrapper = new AdapterWrapper(getContext(),
(StickyListHeadersAdapter) adapter);
}
wrapper.setDivider(mDivider);
wrapper.setDividerHeight(mDividerHeight);
wrapper.registerDataSetObserver(mDataSetChangedObserver);
wrapper.setOnHeaderClickListener(mAdapterHeaderClickListener);
return wrapper;
}
public StickyListHeadersAdapter getWrappedAdapter() {
return mAdapter == null ? null : mAdapter.mDelegate;
}
public View getWrappedView(int position) {
View view = getChildAt(position);
if ((view instanceof WrapperView))
return ((WrapperView) view).mItem;
return view;
}
@Override
protected void dispatchDraw(Canvas canvas) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
scrollChanged(getFirstVisiblePosition());
}
positionSelectorRect();
if (!mAreHeadersSticky || mHeader == null) {
super.dispatchDraw(canvas);
return;
}
if (!mDrawingListUnderStickyHeader) {
mClippingRect
.set(0, mHeaderBottomPosition, getWidth(), getHeight());
canvas.save();
canvas.clipRect(mClippingRect);
}
super.dispatchDraw(canvas);
if (!mDrawingListUnderStickyHeader) {
canvas.restore();
}
drawStickyHeader(canvas);
}
private void positionSelectorRect() {
if (!mSelectorRect.isEmpty()) {
int selectorPosition = getSelectorPosition();
if (selectorPosition >= 0) {
int firstVisibleItem = fixedFirstVisibleItem(getFirstVisiblePosition());
View v = getChildAt(selectorPosition - firstVisibleItem);
if (v instanceof WrapperView) {
WrapperView wrapper = ((WrapperView) v);
mSelectorRect.top = wrapper.getTop() + wrapper.mItemTop;
}
}
}
}
private int getSelectorPosition() {
if (mSelectorPositionField == null) { // not all supported andorid
// version have this variable
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i).getBottom() == mSelectorRect.bottom) {
return i + fixedFirstVisibleItem(getFirstVisiblePosition());
}
}
} else {
try {
return mSelectorPositionField.getInt(this);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return -1;
}
private void drawStickyHeader(Canvas canvas) {
int headerHeight = getHeaderHeight();
int top = mHeaderBottomPosition - headerHeight;
// clip the headers drawing region
mClippingRect.left = getPaddingLeft();
mClippingRect.right = getWidth() - getPaddingRight();
mClippingRect.bottom = top + headerHeight;
mClippingRect.top = mClippingToPadding ? getPaddingTop() : 0;
canvas.save();
canvas.clipRect(mClippingRect);
canvas.translate(getPaddingLeft(), top);
mHeader.draw(canvas);
canvas.restore();
}
private void measureHeader() {
int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth()
-
getPaddingLeft() - getPaddingRight()
-
(isScrollBarOverlay() ? 0 : getVerticalScrollbarWidth()), MeasureSpec.EXACTLY);
int heightMeasureSpec = 0;
ViewGroup.LayoutParams params = mHeader.getLayoutParams();
if (params != null && params.height > 0) {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(params.height,
MeasureSpec.EXACTLY);
} else {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,
MeasureSpec.UNSPECIFIED);
}
mHeader.measure(widthMeasureSpec, heightMeasureSpec);
mHeader.layout(getPaddingLeft(), 0, getWidth()
- getPaddingRight(), mHeader.getMeasuredHeight());
}
private boolean isScrollBarOverlay() {
int scrollBarStyle = getScrollBarStyle();
return scrollBarStyle == SCROLLBARS_INSIDE_OVERLAY || scrollBarStyle == SCROLLBARS_OUTSIDE_OVERLAY;
}
private int getHeaderHeight() {
return mHeader == null ? 0 : mHeader.getMeasuredHeight();
}
@Override
public void setClipToPadding(boolean clipToPadding) {
super.setClipToPadding(clipToPadding);
mClippingToPadding = clipToPadding;
}
private void scrollChanged(int reportedFirstVisibleItem) {
Log.e(“parent”,“scrollChanged”);
int adapterCount = mAdapter == null ? 0 : mAdapter.getCount();
if (adapterCount == 0 || !mAreHeadersSticky) {
return;
}
final int listViewHeaderCount = getHeaderViewsCount();
final int firstVisibleItem = fixedFirstVisibleItem(reportedFirstVisibleItem)
- listViewHeaderCount;
if (firstVisibleItem < 0 || firstVisibleItem > adapterCount - 1) {
reset();
updateHeaderVisibilities();
invalidate();
return;
}
if (mHeaderPosition == null || mHeaderPosition != firstVisibleItem) {
mHeaderPosition = firstVisibleItem;
mCurrentHeaderId = mAdapter.getHeaderId(firstVisibleItem);
mHeader = mAdapter.getHeaderView(mHeaderPosition, mHeader, this);
measureHeader();
}
int childCount = getChildCount();
if (childCount != 0) {
View viewToWatch = null;
int watchingChildDistance = Integer.MAX_VALUE;
boolean viewToWatchIsFooter = false;
for (int i = 0; i < childCount; i++) {
final View child = super.getChildAt(i);
final boolean childIsFooter = mFooterViews != null
&& mFooterViews.contains(child);
final int childDistance = child.getTop()
- (mClippingToPadding ? getPaddingTop() : 0);
if (childDistance < 0) {
continue;
}
if (viewToWatch == null
|| (!viewToWatchIsFooter && !((WrapperView) viewToWatch)
.hasHeader())
|| ((childIsFooter || ((WrapperView) child).hasHeader()) && childDistance < watchingChildDistance)) {
viewToWatch = child;
viewToWatchIsFooter = childIsFooter;
watchingChildDistance = childDistance;
}
}
final int headerHeight = getHeaderHeight();
if (viewToWatch != null
&& (viewToWatchIsFooter || ((WrapperView) viewToWatch)
.hasHeader())) {
if (firstVisibleItem == listViewHeaderCount
&& super.getChildAt(0).getTop() > 0
&& !mClippingToPadding) {
mHeaderBottomPosition = 0;
} else {
-
final int paddingTop = mClippingToPadding ? getPaddingTop()
- 0;
mHeaderBottomPosition = Math.min(viewToWatch.getTop(),
headerHeight + paddingTop);
mHeaderBottomPosition = mHeaderBottomPosition < paddingTop ? headerHeight
- paddingTop
: mHeaderBottomPosition;
}
} else {
mHeaderBottomPosition = headerHeight
- (mClippingToPadding ? getPaddingTop() : 0);
}
}
updateHeaderVisibilities();
invalidate();
}
@Override
public void addFooterView(View v) {
super.addFooterView(v);
if (mFooterViews == null) {
mFooterViews = new ArrayList();
}
mFooterViews.add(v);
}
@Override
public boolean removeFooterView(View v) {
if (super.removeFooterView(v)) {
mFooterViews.remove(v);
return true;
}
return false;
}
private void updateHeaderVisibilities() {
int top = mClippingToPadding ? getPaddingTop() : 0;
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = super.getChildAt(i);
if (child instanceof WrapperView) {
WrapperView wrapperViewChild = (WrapperView) child;
if (wrapperViewChild.hasHeader()) {
View childHeader = wrapperViewChild.mHeader;
if (wrapperViewChild.getTop() < top) {
childHeader.setVisibility(View.INVISIBLE);
} else {
childHeader.setVisibility(View.VISIBLE);
}
}
}
}
}
private int fixedFirstVisibleItem(int firstVisibleItem) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return firstVisibleItem;
}
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i).getBottom() >= 0) {
firstVisibleItem += i;
break;
}
}
// work around to fix bug with firstVisibleItem being to high because
// listview does not take clipToPadding=false into account
if (!mClippingToPadding && getPaddingTop() > 0) {
if (super.getChildAt(0).getTop() > 0) {
if (firstVisibleItem > 0) {
firstVisibleItem -= 1;
}
}
}
return firstVisibleItem;
}
public void setOnHeaderClickListener(
OnHeaderClickListener onHeaderClickListener) {
this.mOnHeaderClickListener = onHeaderClickListener;
}
public void setDrawingListUnderStickyHeader(
boolean drawingListUnderStickyHeader) {
mDrawingListUnderStickyHeader = drawingListUnderStickyHeader;
}
public boolean isDrawingListUnderStickyHeader() {
return mDrawingListUnderStickyHeader;
}
//----------注释-------------
// TODO handle touches better, multitouch etc.
@Override
public boolean onTouchEvent(MotionEvent ev) {
int action = ev.getAction();
if (action == MotionEvent.ACTION_DOWN
&& ev.getY() <= mHeaderBottomPosition) {
mHeaderDownY = ev.getY();
mHeaderBeingPressed = true;
mHeader.setPressed(true);
mHeader.invalidate();
invalidate(0, 0, getWidth(), mHeaderBottomPosition);
return true;
}
if (mHeaderBeingPressed) {
if (Math.abs(ev.getY() - mHeaderDownY) < mViewConfig
.getScaledTouchSlop()) {
if (action == MotionEvent.ACTION_UP
|| action == MotionEvent.ACTION_CANCEL) {
mHeaderDownY = -1;
mHeaderBeingPressed = false;
mHeader.setPressed(false);
mHeader.invalidate();
invalidate(0, 0, getWidth(), mHeaderBottomPosition);
if (mOnHeaderClickListener != null) {
mOnHeaderClickListener.onHeaderClick(this, mHeader,
mHeaderPosition, mCurrentHeaderId, true);
}
}
return true;
} else {
mHeaderDownY = -1;
mHeaderBeingPressed = false;
mHeader.setPressed(false);
mHeader.invalidate();
invalidate(0, 0, getWidth(), mHeaderBottomPosition);
}
}
return super.onTouchEvent(ev);
}
}
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
public interface StickyListHeadersAdapter extends ListAdapter {
View getHeaderView(int position, View convertView, ViewGroup parent);
long getHeaderId(int position);
}
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
/**
*/
class WrapperView extends ViewGroup {
View mItem;
Drawable mDivider;
int mDividerHeight;
View mHeader;
int mItemTop;
public WrapperView(Context c) {
super©;
}
void update(View item, View header, Drawable divider, int dividerHeight) {
if (item == null) {
throw new NullPointerException(“List view item must not be null.”);
}
if (this.mItem != item) {
removeView(this.mItem);
this.mItem = item;
final ViewParent parent = item.getParent();
if(parent != null && parent != this) {
if(parent instanceof ViewGroup) {
((ViewGroup) parent).removeView(item);
}
}
addView(item);
}
if (this.mHeader != header) {
if (this.mHeader != null) {
removeView(this.mHeader);
}
this.mHeader = header;
if (header != null) {
addView(header);
}
}
if (this.mDivider != divider) {
this.mDivider = divider;
this.mDividerHeight = dividerHeight;
invalidate();
}
}
boolean hasHeader() {
return mHeader != null;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int measuredWidth = MeasureSpec.getSize(widthMeasureSpec);
int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(measuredWidth,
MeasureSpec.EXACTLY);
int measuredHeight = 0;
//measure header or divider. when there is a header visible it acts as the divider
if (mHeader != null) {
LayoutParams params = mHeader.getLayoutParams();
if (params != null && params.height > 0) {
mHeader.measure(childWidthMeasureSpec,
MeasureSpec.makeMeasureSpec(params.height, MeasureSpec.EXACTLY));
} else {
mHeader.measure(childWidthMeasureSpec,
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
}
measuredHeight += mHeader.getMeasuredHeight();
} else if (mDivider != null) {
measuredHeight += mDividerHeight;
}
//measure item
LayoutParams params = mItem.getLayoutParams();
if (params != null && params.height > 0) {
mItem.measure(childWidthMeasureSpec,
MeasureSpec.makeMeasureSpec(params.height, MeasureSpec.EXACTLY));
} else {
mItem.measure(childWidthMeasureSpec,
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
}
measuredHeight += mItem.getMeasuredHeight();
setMeasuredDimension(measuredWidth, measuredHeight);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
l = 0;
t = 0;
r = getWidth();
b = getHeight();
if (mHeader != null) {
int headerHeight = mHeader.getMeasuredHeight();
mHeader.layout(l, t, r, headerHeight);
mItemTop = headerHeight;
mItem.layout(l, headerHeight, r, b);
} else if (mDivider != null) {
mDivider.setBounds(l, t, r, mDividerHeight);
mItemTop = mDividerHeight;
mItem.layout(l, mDividerHeight, r, b);
} else {
mItemTop = t;
mItem.layout(l, t, r, b);
}
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mHeader == null && mDivider != null) {
// Drawable.setBounds() does not seem to work pre-honeycomb. So have
// to do this instead
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
canvas.clipRect(0, 0, getWidth(), mDividerHeight);
}
mDivider.draw(canvas);
}
}
}
import android.content.Context;
import android.widget.SectionIndexer;
class SectionIndexerAdapterWrapper extends
AdapterWrapper implements SectionIndexer {
final SectionIndexer mSectionIndexerDelegate;
SectionIndexerAdapterWrapper(Context context,
StickyListHeadersAdapter delegate) {
super(context, delegate);
mSectionIndexerDelegate = (SectionIndexer) delegate;
}
@Override
public int getPositionForSection(int section) {
return mSectionIndexerDelegate.getPositionForSection(section);
}
@Override
public int getSectionForPosition(int position) {
return mSectionIndexerDelegate.getSectionForPosition(position);
}
@Override
public Object[] getSections() {
return mSectionIndexerDelegate.getSections();
}
}
import android.content.Context;
import android.widget.Checkable;
/**
-
A WrapperView that implements the checkable interface
-
@author Emil Sjölander
*/
class CheckableWrapperView extends WrapperView implements Checkable {
public CheckableWrapperView(final Context context) {
super(context);
}
@Override
public boolean isChecked() {
return ((Checkable) mItem).isChecked();
}
@Override
public void setChecked(final boolean checked) {
((Checkable) mItem).setChecked(checked);
}
@Override
public void toggle() {
setChecked(!isChecked());
}
}
import java.util.LinkedList;
import java.util.List;
import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Checkable;
import android.widget.ListAdapter;
/**
-
A {@link ListAdapter} which wraps a {@link StickyListHeadersAdapter} and
-
automatically handles wrapping the result of
-
{@link StickyListHeadersAdapter#getView(int, View, ViewGroup)}
-
and
-
{@link StickyListHeadersAdapter#getHeaderView(int, View, ViewGroup)}
-
appropriately.
-
@author Jake Wharton (jakewharton@gmail.com)
*/
public class AdapterWrapper extends BaseAdapter implements StickyListHeadersAdapter {
public interface OnHeaderClickListener{
public void onHeaderClick(View header, int itemPosition, long headerId);
}
final StickyListHeadersAdapter mDelegate;
private final List mHeaderCache = new LinkedList();
private final Context mContext;
private Drawable mDivider;
private int mDividerHeight;
private OnHeaderClickListener mOnHeaderClickListener;
private DataSetObserver mDataSetObserver = new DataSetObserver() {
@Override
public void onInvalidated() {
mHeaderCache.clear();
AdapterWrapper.super.notifyDataSetInvalidated();
}
@Override
public void onChanged() {
AdapterWrapper.super.notifyDataSetChanged();
}
};
AdapterWrapper(Context context,
StickyListHeadersAdapter delegate) {
this.mContext = context;
this.mDelegate = delegate;
delegate.registerDataSetObserver(mDataSetObserver);
}
void setDivider(Drawable divider) {
this.mDivider = divider;
}
void setDividerHeight(int dividerHeight) {
this.mDividerHeight = dividerHeight;
}
@Override
public boolean areAllItemsEnabled() {
return mDelegate.areAllItemsEnabled();
}
@Override
public boolean isEnabled(int position) {
return mDelegate.isEnabled(position);
}
@Override
public int getCount() {
return mDelegate.getCount();
}
@Override
public Object getItem(int position) {
return mDelegate.getItem(position);
}
@Override
public long getItemId(int position) {
return mDelegate.getItemId(position);
}
@Override
public boolean hasStableIds() {
return mDelegate.hasStableIds();
}
@Override
public int getItemViewType(int position) {
return mDelegate.getItemViewType(position);
}
@Override
public int getViewTypeCount() {
return mDelegate.getViewTypeCount();
}
@Override
public boolean isEmpty() {
return mDelegate.isEmpty();
}
/**
- Will recycle header from {@link WrapperView} if it exists
*/
private void recycleHeaderIfExists(WrapperView wv) {
View header = wv.mHeader;
if (header != null) {
mHeaderCache.add(header);
}
}
/**
-
Get a header view. This optionally pulls a header from the supplied
-
{@link WrapperView} and will also recycle the divider if it exists.
*/
private View configureHeader(WrapperView wv, final int position) {
View header = wv.mHeader == null ? popHeader() : wv.mHeader;
header = mDelegate.getHeaderView(position, header, wv);
if (header == null) {
throw new NullPointerException(“Header view must not be null.”);
}
//if the header isn’t clickable, the listselector will be drawn on top of the header
header.setClickable(true);
header.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(mOnHeaderClickListener != null){
long headerId = mDelegate.getHeaderId(position);
mOnHeaderClickListener.onHeaderClick(v, position, headerId);
}
}
});
return header;
}
private View popHeader() {
if(mHeaderCache.size() > 0) {
return mHeaderCache.remove(0);
}
return null;
}
private boolean previousPositionHasSameHeader(int position) {
return position != 0
&& mDelegate.getHeaderId(position) == mDelegate
.getHeaderId(position - 1);
}
@Override
public WrapperView getView(int position, View convertView, ViewGroup parent) {
WrapperView wv = (convertView == null) ? new WrapperView(mContext) : (WrapperView) convertView;
View item = mDelegate.getView(position, wv.mItem, wv);
View header = null;
if (previousPositionHasSameHeader(position)) {
recycleHeaderIfExists(wv);
} else {
header = configureHeader(wv, position);
}
if((item instanceof Checkable) && !(wv instanceof CheckableWrapperView)) {
// Need to create Checkable subclass of WrapperView for ListView to work correctly
wv = new CheckableWrapperView(mContext);
} else if(!(item instanceof Checkable) && (wv instanceof CheckableWrapperView)) {
wv = new WrapperView(mContext);
}
wv.update(item, header, mDivider, mDividerHeight);
return wv;
}
public void setOnHeaderClickListener(OnHeaderClickListener onHeaderClickListener){
this.mOnHeaderClickListener = onHeaderClickListener;
}
@Override
public boolean equals(Object o) {
return mDelegate.equals(o);
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
return ((BaseAdapter) mDelegate).getDropDownView(position, convertView, parent);
}
@Override
public int hashCode() {
return mDelegate.hashCode();
}
@Override
public void notifyDataSetChanged() {
((BaseAdapter) mDelegate).notifyDataSetChanged();
}
@Override
public void notifyDataSetInvalidated() {
((BaseAdapter) mDelegate).notifyDataSetInvalidated();
}
@Override
public String toString() {
return mDelegate.toString();
}
@Override
public View getHeaderView(int position, View convertView, ViewGroup parent) {
return mDelegate.getHeaderView(position, convertView, parent);
}
@Override
public long getHeaderId(int position) {
return mDelegate.getHeaderId(position);
}
}
上面的几个类大家直接建一个目录拷贝进去就行 下面开始写项目的代码
Activity
public class CitySelectListActivity extends Activity implements
StickyListHeadersListView.OnHeaderClickListener, AdapterView.OnItemClickListener
, StickyListHeadersListView.OnLoadingMoreLinstener {
CityLetterSortAdapter mAdapter;
StickyListHeadersListView stickyLV;
private static final String TAG = CitySelectListActivity.class.getSimpleName();
private CharacterParser mCharacterParser;
private List sourceDateFilterList = new ArrayList();
private EditText searchEt;
private List sourceDateList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_city_select);
initView();
}
public void initView() {
mCharacterParser = CharacterParser.getInstance();
PinyinComparator pinyinComparator = new PinyinComparator();
sourceDateList = filledData(getResources().getStringArray(R.array.cities_data));
Collections.sort(sourceDateList, pinyinComparator);
mAdapter = new CityLetterSortAdapter(this, sourceDateList);
stickyLV = (StickyListHeadersListView) this.findViewById(R.id.stickyList);
stickyLV.setAdapter(mAdapter);
stickyLV.setOnItemClickListener(this);
stickyLV.setOnHeaderClickListener(this);
stickyLV.setLoadingMoreListener(this);
LetterSideBar letterSideBar = (LetterSideBar) findViewById(R.id.cs_letter_sb);
letterSideBar.setOnTouchingLetterChangedListener(
new LetterSideBar.OnTouchingLetterChangedListener() {
@Override
public void onTouchingLetterChanged(String letter) {
Logger.d(TAG, "onTouchingLetterChanged letter: " + letter);
int jumpPos = mAdapter.getPositionForSection(letter.charAt(0));
stickyLV.setSelection(jumpPos);
}
});
letterSideBar.setTextView((TextView) findViewById(R.id.cs_selected_letter_tv));
searchEt = (EditText) findViewById(R.id.cs_search_et);
searchEt.setVisibility(View.VISIBLE);
searchEt.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (charSequence.toString().length() == 0) {
mAdapter.updateListView(sourceDateList);
mAdapter.notifyDataSetChanged();
} else {
String searchText = searchEt.getText().toString();
if (TextUtils.isEmpty(searchText)) {
SingleToast.show(getApplicationContext(), R.string.msg_keyword_is_empty);
}
sourceDateFilterList.clear();
for (int h = 0; h < sourceDateList.size(); h++) {
if (sourceDateList.get(h).getName().contains(searchText)) {
sourceDateFilterList.add(sourceDateList.get(h));
}
}
if (sourceDateFilterList.size() <= 0) {
// noFilterPhoneFriends();
} else {
mAdapter.updateListView(sourceDateFilterList);
mAdapter.notifyDataSetChanged();
}
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
}
private List filledData(String[] date) {
List mSortList = new ArrayList();
for (int i = 0, n = date.length; i < n; i++) {
SortModel sortModel = new SortModel();
sortModel.setName(date[i]);
String pinyin = mCharacterParser.getSelling(date[i]);
sortModel.setPinyin(pinyin);
String sortString = pinyin.substring(0, 1).toUpperCase();
if (sortString.matches(“[A-Z]”)) {
sortModel.setSortLetter(sortString.toUpperCase());
} else {
sortModel.setSortLetter(“#”);
}
mSortList.add(sortModel);
}
return mSortList;
}
@Override
public void OnLoadingMore() {
}
@Override
public void onHeaderClick(StickyListHeadersListView l, View header,
int itemPosition, long headerId, boolean currentlySticky) {
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
String city = ((SortModel) mAdapter.getItem(position)).getName();
setResult(RESULT_OK, getIntent().putExtra(Constants.EXTRA_KEY_SELECT_CITY, city));
finish();
}
}
Adapter
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.SectionIndexer;
import android.widget.TextView;
import com.ccvideo.R;
import com.yizhibo.video.bean.SortModel;
import com.yizhibo.video.utils.Utils;
import com.yizhibo.video.view.stickylistview.StickyListHeadersAdapter;
public class CityLetterSortAdapter extends BaseAdapter
implements StickyListHeadersAdapter, SectionIndexer, Filterable {
private static final String TAG = CityLetterSortAdapter.class.getSimpleName();
private List mListAll = new ArrayList();
private List mList = null;
private Context mContext;
public CityLetterSortAdapter(Context mContext, List list) {
this.mContext = mContext;
this.mList = list;
mListAll.clear();
this.mListAll.addAll(list);
}
public void updateListView(List list) {
this.mList = list;
this.mListAll = list;
notifyDataSetChanged();
}
public int getCount() {
return this.mList.size();
}
public Object getItem(int position) {
return mList.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View view, ViewGroup viewGroup) {
ViewHolder viewHolder = null;
if (view == null) {
viewHolder = new ViewHolder();
view = LayoutInflater.from(mContext).inflate(R.layout.item_city_letter_sort, viewGroup, false);
viewHolder.tvTitle = (TextView) view.findViewById(R.id.title);
view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) view.getTag();
}
if (position >= mList.size()) {
Utils.statisticError(TAG, “City list adapter size error !”);
return view;
}
viewHolder.tvTitle.setText(this.mList.get(position).getName());
return view;
}
@Override
public Filter getFilter() {
return new Filter() {
@Override
protected FilterResults performFiltering(CharSequence charSequence) {
FilterResults filterResults = new FilterResults();
ArrayList filterArrayName = new ArrayList();
String search = charSequence.toString().toLowerCase();
for (int i = 0, n = mListAll.size(); i < n; i++) {
String name = mListAll.get(i).getPinyin();
if (name.toLowerCase().startsWith(search)) {
filterArrayName.add(mListAll.get(i));
}
}
filterResults.count = filterArrayName.size();
filterResults.values = filterArrayName;
return filterResults;
}
@Override
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
mList.clear();
mList.addAll((List) filterResults.values);
notifyDataSetChanged();
}
};
}
@Override
public View getHeaderView(int position, View view, ViewGroup viewGroup) {
HeaderViewHolder hViewHolder;
if (view == null) {
hViewHolder = new HeaderViewHolder();
view = LayoutInflater.from(mContext).inflate(R.layout.item_sticky_header, viewGroup, false);
hViewHolder.tvLetter = (TextView) view.findViewById(R.id.sticky_header_letter_tv);
view.setTag(hViewHolder);
} else {
hViewHolder = (HeaderViewHolder) view.getTag();
}
hViewHolder.tvLetter.setText(mList.get(position).getSortLetter());
return view;
}
@Override
public long getHeaderId(int position) {
return mList.get(position).getSortLetter().subSequence(0, 1).charAt(0);
}
final static class HeaderViewHolder {
TextView tvLetter;
}
final static class ViewHolder {
TextView tvTitle;
}
/**
- 根据ListView的当前位置获取分类的首字母的Char ascii值
*/
public int getSectionForPosition(int position) {
return mList.get(position).getSortLetter().charAt(0);
}
/**
- 根据分类的首字母的Char ascii值获取其第一次出现该首字母的位置
*/
public int getPositionForSection(int section) {
for (int i = 0; i < getCount(); i++) {
String sortStr = mList.get(i).getSortLetter();
char firstChar = sortStr.toUpperCase().charAt(0);
if (firstChar == section) {
return i;
}
}
return -1;
}
/**
- 提取英文的首字母,非英文字母用#代替。
*/
private String getAlpha(String letter) {
String sortStr = letter.trim().substring(0, 1).toUpperCase();
// 正则表达式,判断首字母是否是英文字母
if (sortStr.matches(“[A-Z]”)) {
return sortStr;
} else {
return “#”;
}
}
@Override
public Object[] getSections() {
return null;
}
}
Layout
activity_city_select.xml
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android”
android:fitsSystemWindows=“true”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:orientation=“vertical”>
<EditText
android:id=“@+id/cs_search_et”
android:layout_width=“match_parent”
android:layout_height=“34dp”
android:layout_margin=“10dp”
android:paddingLeft=“5dp”
android:singleLine=“true”
android:imeOptions=“actionSearch”
android:layout_gravity=“center_vertical”
android:hint=“@string/city_select”
android:visibility=“gone”
android:drawableLeft=“@drawable/icon_search”
android:textSize=“12sp”
android:background=“@drawable/search_box_shape”/>
<com.yizhibo.video.view.stickylistview.StickyListHeadersListView
android:id=“@+id/stickyList”
android:layout_width=“match_parent”
android:layout_below=“@id/cs_search_et”
android:layout_height=“wrap_content”
android:cacheColorHint=“@android:color/transparent”
android:listSelector=“@drawable/list_item_selector”/>
<com.yizhibo.video.view.LetterSideBar
android:id=“@+id/cs_letter_sb”
android:layout_width=“20dp”
android:layout_height=“match_parent”
android:layout_below=“@id/cs_search_et”
android:layout_alignParentRight=“true”/>
<TextView
android:id=“@+id/cs_selected_letter_tv”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_centerInParent=“true”
android:textSize=“60sp”
android:textColor=“@color/text_gray”/>
item_city_letter_sort.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout
xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:layout_height=“@dimen/list_item_video_limit_height”
android:paddingLeft=“9dp”
android:paddingRight=“15dp”
android:gravity=“center_vertical”
android:background=“@color/white”
android:orientation=“horizontal”>
<TextView
android:id=“@+id/title”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_gravity=“center_vertical”
android:layout_marginLeft=“12dip”
android:gravity=“center_vertical”
android:paddingBottom=“10dip”
android:paddingTop=“10dip”
android:layout_weight=“1”
android:text=“”
android:textSize=“@dimen/text_size_13”
android:textColor=“@color/text_subtitle”/>
<TextView
android:id=“@+id/name_code_txv”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_gravity=“center_vertical|right”
android:gravity=“right”
android:layout_weight=“1”
android:paddingRight=“10dip”
android:paddingBottom=“10dip”
android:paddingTop=“10dip”
android:text=“”
android:textSize=“@dimen/text_size_13”
android:textColor=“@color/text_subtitle”/>
LetterSideBar
package com.yizhibo.video.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;
import com.ccvideo.*;
public class LetterSideBar extends View {
private OnTouchingLetterChangedListener onTouchingLetterChangedListener;
public static String[] mLetters = { “#”, “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”, “J”, “K”, “L”, “M”,
“N”, “O”, “P”, “Q”, “R”, “S”, “T”, “U”, “V”, “W”, “X”, “Y”, “Z”
};
private int mChooseIndex = -1;
private Paint mPaint = new Paint();
private TextView mTextDialog;
public LetterSideBar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public LetterSideBar(Context context, AttributeSet attrs) {
super(context, attrs);
}
public LetterSideBar(Context context) {
super(context);
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int height = getHeight();
int width = getWidth();
int singleHeight = height / mLetters.length;
for (int i = 0; i < mLetters.length; i++) {
mPaint.setColor(Color.rgb(33, 65, 98));
// mPaint.setColor(Color.WHITE);
mPaint.setTypeface(Typeface.DEFAULT);
mPaint.setAntiAlias(true);
mPaint.setTextSize(30);
// Selected state
if (i == mChooseIndex) {
mPaint.setColor(getResources().getColor(R.color.text_common));
mPaint.setFakeBoldText(true);
}
float x = width / 2 - mPaint.measureText(mLetters[i]) / 2;
float y = singleHeight * i + singleHeight;
canvas.drawText(mLetters[i], x, y, mPaint);
mPaint.reset();
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
final int action = event.getAction();
final float y = event.getY();
final int oldChooseIndex = mChooseIndex;
final OnTouchingLetterChangedListener listener = onTouchingLetterChangedListener;
// 点击y坐标所占总高度的比例*b数组的长度就等于点击b中的个数.
final int chooseIndex = (int) (y / getHeight() * mLetters.length);
switch (action) {
case MotionEvent.ACTION_UP:
setBackgroundResource(android.R.color.transparent);
mChooseIndex = -1;//
invalidate();
if (mTextDialog != null) {
mTextDialog.setVisibility(View.INVISIBLE);
}
break;
default:
setBackgroundResource(R.color.black_alpha_percent_30);
if (oldChooseIndex != chooseIndex) {
if (chooseIndex >= 0 && chooseIndex < mLetters.length) {
if (listener != null) {
listener.onTouchingLetterChanged(mLetters[chooseIndex]);
}
if (mTextDialog != null) {
mTextDialog.setText(mLetters[chooseIndex]);
mTextDialog.setVisibility(View.VISIBLE);
}
mChooseIndex = chooseIndex;
invalidate();
}
}
break;
}
return true;
}
public void setTextView(TextView mTextDialog) {
this.mTextDialog = mTextDialog;
}
public void setOnTouchingLetterChangedListener(
OnTouchingLetterChangedListener onTouchingLetterChangedListener) {
this.onTouchingLetterChangedListener = onTouchingLetterChangedListener;
}
public interface OnTouchingLetterChangedListener {
void onTouchingLetterChanged(String letter);
}
}
item_sticky_header.xml
<?xml version="1.0" encoding="utf-8"?><TextView
xmlns:android=“http://schemas.android.com/apk/res/android”
android:id=“@+id/sticky_header_letter_tv”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:background=“@color/default_line_color”
android:gravity=“center_vertical|left”
android:padding=“9dip”
android:text=“”
android:textColor=“@color/text_brown”
android:textSize=“@dimen/text_size_12”/>
SortModel.java
public class SortModel extends BaseSortModel {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
CharacterParser.java
package com.yizhibo.video.utils;
/**
* Java汉字转换为拼音
*/
public class CharacterParser {
private static int[] pyvalue = new int[]{-20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, -20230, -20051, -20036, -20032,
-20026, -20002, -19990, -19986, -19982, -19976, -19805, -19784, -19775, -19774, -19763, -19756, -19751, -19746, -19741, -19739, -19728,
-19725, -19715, -19540, -19531, -19525, -19515, -19500, -19484, -19479, -19467, -19289, -19288, -19281, -19275, -19270, -19263, -19261,
-19249, -19243, -19242, -19238, -19235, -19227, -19224, -19218, -19212, -19038, -19023, -19018, -19006, -19003, -18996, -18977, -18961,
-18952, -18783, -18774, -18773, -18763, -18756, -18741, -18735, -18731, -18722, -18710, -18697, -18696, -18526, -18518, -18501, -18490,
-18478, -18463, -18448, -18447, -18446, -18239, -18237, -18231, -18220, -18211, -18201, -18184, -18183, -18181, -18012, -17997, -17988,
-17970, -17964, -17961, -17950, -17947, -17931, -17928, -17922, -17759, -17752, -17733, -17730, -17721, -17703, -17701, -17697, -17692,
-17683, -17676, -17496, -17487, -17482, -17468, -17454, -17433, -17427, -17417, -17202, -17185, -16983, -16970, -16942, -16915, -16733,
-16708, -16706, -16689, -16664, -16657, -16647, -16474, -16470, -16465, -16459, -16452, -16448, -16433, -16429, -16427, -16423, -16419,
-16412, -16407, -16403, -16401, -16393, -16220, -16216, -16212, -16205, -16202, -16187, -16180, -16171, -16169, -16158, -16155, -15959,
-15958, -15944, -15933, -15920, -15915, -15903, -15889, -15878, -15707, -15701, -15681, -15667, -15661, -15659, -15652, -15640, -15631,
-15625, -15454, -15448, -15436, -15435, -15419, -15416, -15408, -15394, -15385, -15377, -15375, -15369, -15363, -15362, -15183, -15180,
-15165, -15158, -15153, -15150, -15149, -15144, -15143, -15141, -15140, -15139, -15128, -15121, -15119, -15117, -15110, -15109, -14941,
-14937, -14933, -14930, -14929, -14928, -14926, -14922, -14921, -14914, -14908, -14902, -14894, -14889, -14882, -14873, -14871, -14857,
-14678, -14674, -14670, -14668, -14663, -14654, -14645, -14630, -14594, -14429, -14407, -14399, -14384, -14379, -14368, -14355, -14353,
-14345, -14170, -14159, -14151, -14149, -14145, -14140, -14137, -14135, -14125, -14123, -14122, -14112, -14109, -14099, -14097, -14094,
-14092, -14090, -14087, -14083, -13917, -13914, -13910, -13907, -13906, -13905, -13896, -13894, -13878, -13870, -13859, -13847, -13831,
-13658, -13611, -13601, -13406, -13404, -13400, -13398, -13395, -13391, -13387, -13383, -13367, -13359, -13356, -13343, -13340, -13329,
-13326, -13318, -13147, -13138, -13120, -13107, -13096, -13095, -13091, -13076, -13068, -13063, -13060, -12888, -12875, -12871, -12860,
-12858, -12852, -12849, -12838, -12831, -12829, -12812, -12802, -12607, -12597, -12594, -12585, -12556, -12359, -12346, -12320, -12300,
-12120, -12099, -12089, -12074, -12067, -12058, -12039, -11867, -11861, -11847, -11831, -11798, -11781, -11604, -11589, -11536, -11358,
-11340, -11339, -11324, -11303, -11097, -11077, -11067, -11055, -11052, -11045, -11041, -11038, -11024, -11020, -11019, -11018, -11014,
-10838, -10832, -10815, -10800, -10790, -10780, -10764, -10587, -10544, -10533, -10519, -10331, -10329, -10328, -10322, -10315, -10309,
-10307, -10296, -10281, -10274, -10270, -10262, -10260, -10256, -10254};
public static String[] pystr = new String[]{“a”, “ai”, “an”, “ang”, “ao”, “ba”, “bai”, “ban”, “bang”, “bao”, “bei”, “ben”, “beng”, “bi”, “bian”,
“biao”, “bie”, “bin”, “bing”, “bo”, “bu”, “ca”, “cai”, “can”, “cang”, “cao”, “ce”, “ceng”, “cha”, “chai”, “chan”, “chang”, “chao”, “che”,
“chen”, “cheng”, “chi”, “chong”, “chou”, “chu”, “chuai”, “chuan”, “chuang”, “chui”, “chun”, “chuo”, “ci”, “cong”, “cou”, “cu”, “cuan”,
“cui”, “cun”, “cuo”, “da”, “dai”, “dan”, “dang”, “dao”, “de”, “deng”, “di”, “dian”, “diao”, “die”, “ding”, “diu”, “dong”, “dou”, “du”,
“duan”, “dui”, “dun”, “duo”, “e”, “en”, “er”, “fa”, “fan”, “fang”, “fei”, “fen”, “feng”, “fo”, “fou”, “fu”, “ga”, “gai”, “gan”, “gang”,
“gao”, “ge”, “gei”, “gen”, “geng”, “gong”, “gou”, “gu”, “gua”, “guai”, “guan”, “guang”, “gui”, “gun”, “guo”, “ha”, “hai”, “han”, “hang”,
“hao”, “he”, “hei”, “hen”, “heng”, “hong”, “hou”, “hu”, “hua”, “huai”, “huan”, “huang”, “hui”, “hun”, “huo”, “ji”, “jia”, “jian”,
“jiang”, “jiao”, “jie”, “jin”, “jing”, “jiong”, “jiu”, “ju”, “juan”, “jue”, “jun”, “ka”, “kai”, “kan”, “kang”, “kao”, “ke”, “ken”,
“keng”, “kong”, “kou”, “ku”, “kua”, “kuai”, “kuan”, “kuang”, “kui”, “kun”, “kuo”, “la”, “lai”, “lan”, “lang”, “lao”, “le”, “lei”, “leng”,
“li”, “lia”, “lian”, “liang”, “liao”, “lie”, “lin”, “ling”, “liu”, “long”, “lou”, “lu”, “lv”, “luan”, “lue”, “lun”, “luo”, “ma”, “mai”,
“man”, “mang”, “mao”, “me”, “mei”, “men”, “meng”, “mi”, “mian”, “miao”, “mie”, “min”, “ming”, “miu”, “mo”, “mou”, “mu”, “na”, “nai”,
“nan”, “nang”, “nao”, “ne”, “nei”, “nen”, “neng”, “ni”, “nian”, “niang”, “niao”, “nie”, “nin”, “ning”, “niu”, “nong”, “nu”, “nv”, “nuan”,
“nue”, “nuo”, “o”, “ou”, “pa”, “pai”, “pan”, “pang”, “pao”, “pei”, “pen”, “peng”, “pi”, “pian”, “piao”, “pie”, “pin”, “ping”, “po”, “pu”,
“qi”, “qia”, “qian”, “qiang”, “qiao”, “qie”, “qin”, “qing”, “qiong”, “qiu”, “qu”, “quan”, “que”, “qun”, “ran”, “rang”, “rao”, “re”,
“ren”, “reng”, “ri”, “rong”, “rou”, “ru”, “ruan”, “rui”, “run”, “ruo”, “sa”, “sai”, “san”, “sang”, “sao”, “se”, “sen”, “seng”, “sha”,
“shai”, “shan”, “shang”, “shao”, “she”, “shen”, “sheng”, “shi”, “shou”, “shu”, “shua”, “shuai”, “shuan”, “shuang”, “shui”, “shun”,
“shuo”, “si”, “song”, “sou”, “su”, “suan”, “sui”, “sun”, “suo”, “ta”, “tai”, “tan”, “tang”, “tao”, “te”, “teng”, “ti”, “tian”, “tiao”,
“tie”, “ting”, “tong”, “tou”, “tu”, “tuan”, “tui”, “tun”, “tuo”, “wa”, “wai”, “wan”, “wang”, “wei”, “wen”, “weng”, “wo”, “wu”, “xi”,
“xia”, “xian”, “xiang”, “xiao”, “xie”, “xin”, “xing”, “xiong”, “xiu”, “xu”, “xuan”, “xue”, “xun”, “ya”, “yan”, “yang”, “yao”, “ye”, “yi”,
“yin”, “ying”, “yo”, “yong”, “you”, “yu”, “yuan”, “yue”, “yun”, “za”, “zai”, “zan”, “zang”, “zao”, “ze”, “zei”, “zen”, “zeng”, “zha”,
“zhai”, “zhan”, “zhang”, “zhao”, “zhe”, “zhen”, “zheng”, “zhi”, “zhong”, “zhou”, “zhu”, “zhua”, “zhuai”, “zhuan”, “zhuang”, “zhui”,
“zhun”, “zhuo”, “zi”, “zong”, “zou”, “zu”, “zuan”, “zui”, “zun”, “zuo”};
private StringBuilder buffer;
private String resource;
private static CharacterParser characterParser = new CharacterParser();
public static CharacterParser getInstance() {
return characterParser;
}
public String getResource() {
return resource;
}
public void setResource(String resource) {
this.resource = resource;
}
/**
* 汉字转成ASCII码 * * @param chs * @return
*/
private int getChsAscii(String chs) {
int asc = 0;
try {
byte[] bytes = chs.getBytes(“gb2312”);
if (bytes.length > 2 || bytes.length <= 0) {
throw new RuntimeException(“illegal resource string”);
}
if (bytes.length == 1) {
asc = bytes[0];
}
if (bytes.length == 2) {
int hightByte = 256 + bytes[0];
int lowByte = 256 + bytes[1];
asc = (256 * hightByte + lowByte) - 256 * 256;
}
} catch (Exception e) {
System.out.println(“ERROR:ChineseSpelling.class-getChsAscii(String chs)” + e);
}
return asc;
}
/**
* 单字解析 * * @param str * @return
*/
public String convert(String str) {
String result = null;
int ascii = getChsAscii(str);
if (ascii > 0 && ascii < 160) {
result = String.valueOf((char) ascii);
} else {
for (int i = (pyvalue.length - 1); i >= 0; i–) {
if (pyvalue[i] <= ascii) {
result = pystr[i];
break;
}
}
}
return result;
}
/**
* 词组解析 * * @param chs * @return
*/
public String getSelling(String chs) {
String key, value;
buffer = new StringBuilder();
for (int i = 0; i < chs.length(); i++) {
key = chs.substring(i, i + 1);
if (key.getBytes().length >= 2) {
value = convert(key);
if (value == null) {
value = “unknown”;
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
![](https://i-blog.csdnimg.cn/blog_migrate/ea6ae1f946c794aa87c1728778ca6157.jpeg)
最后
其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。
上面分享的腾讯、头条、阿里、美团、字节跳动等公司2019-2021年的高频面试题,博主还把这些技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,上面只是以图片的形式给大家展示一部分。
【Android思维脑图(技能树)】
知识不体系?这里还有整理出来的Android进阶学习的思维脑图,给大家参考一个方向。
【Android高级架构视频学习资源】
**Android部分精讲视频领取学习后更加是如虎添翼!**进军BATJ大厂等(备战)!现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
CharacterParser getInstance() {
return characterParser;
}
public String getResource() {
return resource;
}
public void setResource(String resource) {
this.resource = resource;
}
/**
* 汉字转成ASCII码 * * @param chs * @return
*/
private int getChsAscii(String chs) {
int asc = 0;
try {
byte[] bytes = chs.getBytes(“gb2312”);
if (bytes.length > 2 || bytes.length <= 0) {
throw new RuntimeException(“illegal resource string”);
}
if (bytes.length == 1) {
asc = bytes[0];
}
if (bytes.length == 2) {
int hightByte = 256 + bytes[0];
int lowByte = 256 + bytes[1];
asc = (256 * hightByte + lowByte) - 256 * 256;
}
} catch (Exception e) {
System.out.println(“ERROR:ChineseSpelling.class-getChsAscii(String chs)” + e);
}
return asc;
}
/**
* 单字解析 * * @param str * @return
*/
public String convert(String str) {
String result = null;
int ascii = getChsAscii(str);
if (ascii > 0 && ascii < 160) {
result = String.valueOf((char) ascii);
} else {
for (int i = (pyvalue.length - 1); i >= 0; i–) {
if (pyvalue[i] <= ascii) {
result = pystr[i];
break;
}
}
}
return result;
}
/**
* 词组解析 * * @param chs * @return
*/
public String getSelling(String chs) {
String key, value;
buffer = new StringBuilder();
for (int i = 0; i < chs.length(); i++) {
key = chs.substring(i, i + 1);
if (key.getBytes().length >= 2) {
value = convert(key);
if (value == null) {
value = “unknown”;
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-RmBkJhyk-1712553856119)]
[外链图片转存中…(img-HLhsQVW3-1712553856120)]
[外链图片转存中…(img-hS3emSyF-1712553856120)]
[外链图片转存中…(img-ZpSjLDvw-1712553856121)]
[外链图片转存中…(img-KB9pQUXQ-1712553856121)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
![](https://i-blog.csdnimg.cn/blog_migrate/ea6ae1f946c794aa87c1728778ca6157.jpeg)
最后
其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。
上面分享的腾讯、头条、阿里、美团、字节跳动等公司2019-2021年的高频面试题,博主还把这些技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,上面只是以图片的形式给大家展示一部分。
【Android思维脑图(技能树)】
知识不体系?这里还有整理出来的Android进阶学习的思维脑图,给大家参考一个方向。
[外链图片转存中…(img-IGmlilAK-1712553856122)]
【Android高级架构视频学习资源】
**Android部分精讲视频领取学习后更加是如虎添翼!**进军BATJ大厂等(备战)!现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!