안 드 로 이 드 프로 그래 밍 은 가짜 미 단 이나 타 오 바 오의 다단 계 분류 메뉴 효과 예제[데모 소스 다운로드 첨부]를 실현 합 니 다.
여기 서 실현 해 야 할 것 은 미 단/타 오 바 오/바 이 두 찹쌀 다단 계 분류 메뉴 효과 이다.분류 수량 이 매우 많 을 때 2 급 분 류 를 고려 할 수 있 는데,예 를 들 어 미 단 과 같은 표현 방식 은 좋 은 선택 이다.
우선 위의 효과 그림:
주 코드:
1.PopupWindow 초기 화 과정:
popupWindow = new PopupWindow(this);
View view = LayoutInflater.from(this).inflate(R.layout.popup_layout, null);
leftLV = (ListView) view.findViewById(R.id.pop_listview_left);
rightLV = (ListView) view.findViewById(R.id.pop_listview_right);
popupWindow.setContentView(view);
popupWindow.setBackgroundDrawable(new PaintDrawable());
popupWindow.setFocusable(true);
popupWindow.setHeight(ScreenUtils.getScreenH(this) * 2 / 3);
popupWindow.setWidth(ScreenUtils.getScreenW(this));
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
darkView.startAnimation(animOut);
darkView.setVisibility(View.GONE);
leftLV.setSelection(0);
rightLV.setSelection(0);
}
});
2.왼쪽 메뉴 클릭 이벤트:
// ListView
leftLV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//
List<SecondClassItem> list2 = firstList.get(position).getSecondList();
// ,
if (list2 == null || list2.size() == 0) {
popupWindow.dismiss();
int firstId = firstList.get(position).getId();
String selectedName = firstList.get(position).getName();
handleResult(firstId, -1, selectedName);
return;
}
FirstClassAdapter adapter = (FirstClassAdapter) (parent.getAdapter());
// item,
if (adapter.getSelectedPosition() == position){
return;
}
// ,
adapter.setSelectedPosition(position);
adapter.notifyDataSetChanged();
//
updateSecondListView(list2, secondAdapter);
}
});
3.오른쪽 메뉴 클릭 이벤트:
// ListView
rightLV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// popupWindow,
popupWindow.dismiss();
int firstPosition = firstAdapter.getSelectedPosition();
int firstId = firstList.get(firstPosition).getId();
int secondId = firstList.get(firstPosition).getSecondList().get(position).getId();
String selectedName = firstList.get(firstPosition).getSecondList().get(position)
.getName();
handleResult(firstId, secondId, selectedName);
}
});
4.상단 탭 클릭 이벤트(분류 메뉴 표시/숨 기기)
if (popupWindow.isShowing()) {
popupWindow.dismiss();
} else {
popupWindow.showAsDropDown(findViewById(R.id.main_div_line));
popupWindow.setAnimationStyle(-1);
//
darkView.startAnimation(animIn);
darkView.setVisibility(View.VISIBLE);
}
5.왼쪽 클릭 에 따라 오른쪽 ListView 새로 고침
// ListView
private void updateSecondListView(List<SecondClassItem> list2,
SecondClassAdapter secondAdapter) {
secondList.clear();
secondList.addAll(list2);
secondAdapter.notifyDataSetChanged();
}
전체 인 스 턴 스 코드 는 여 기 를 클릭 하 십시오본 사이트 다운로드더 많은 안 드 로 이 드 관련 내용 에 관심 이 있 는 독자 들 은 본 사이트 의 주 제 를 볼 수 있다.,,,,,,,
본 고 에서 말 한 것 이 여러분 의 안 드 로 이 드 프로 그래 밍 에 도움 이 되 기 를 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Bitrise에서 배포 어플리케이션 설정 테스트하기이 글은 Bitrise 광고 달력의 23일째 글입니다. 자체 또는 당사 등에서 Bitrise 구축 서비스를 사용합니다. 그나저나 며칠 전 Bitrise User Group Meetup #3에서 아래 슬라이드를 발표했...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.