├── .gitignore ├── DEMO.iml ├── README.md ├── build.gradle ├── proguard-rules.pro ├── screen_shot.gif └── src └── main ├── AndroidManifest.xml ├── java └── com │ └── microjixl │ └── demo │ ├── DataAdapter.java │ ├── DemoActivity.java │ └── SelectFragment.java └── res ├── anim ├── fade_in.xml ├── fade_out.xml ├── popupwindow_slide_in_from_top.xml └── popupwindow_slide_out_to_top.xml ├── drawable-hdpi ├── arrow_dark_down.png ├── arrow_dark_up.png ├── back_icon.png └── ic_launcher.png ├── drawable-mdpi └── ic_launcher.png ├── drawable-xhdpi └── ic_launcher.png ├── drawable-xxhdpi └── ic_launcher.png ├── drawable ├── round_stoke_bg.xml └── select_menu_bg.xml ├── layout ├── activity_demo.xml ├── item_menu.xml └── select_choice.xml └── values ├── colors.xml ├── strings.xml └── styles.xml /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /DEMO.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LevelsChoice 2 | ============ 3 | 4 | it looks like dazhongdianping's search type bar. it is stable and flexible. 5 | 6 | it implement with fragment.you can add any complex view in it. enjoy it 7 | 8 | screen shot 9 | 10 | ![alt text](https://raw.githubusercontent.com/microjixl/LevelsChoice/master/screen_shot.gif) 11 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'android' 2 | 3 | android { 4 | compileSdkVersion 19 5 | buildToolsVersion "19.1.0" 6 | 7 | defaultConfig { 8 | packageName "com.microjixl.demo" 9 | minSdkVersion 14 10 | targetSdkVersion 19 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | runProguard false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | } 25 | -------------------------------------------------------------------------------- /proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/coco/work/programfile/android-sdk-linux/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /screen_shot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microjixl/LevelsChoice/a41cc12ff133881762ba0fd33cf9a952b154a14f/screen_shot.gif -------------------------------------------------------------------------------- /src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/java/com/microjixl/demo/DataAdapter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * copyright(C)2014- 4 | * 5 | */ 6 | package com.microjixl.demo; 7 | 8 | import android.content.Context; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.BaseAdapter; 13 | import android.widget.TextView; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | /** 19 | * @author jixiaolong 20 | */ 21 | public class DataAdapter extends BaseAdapter{ 22 | private List mList; 23 | private LayoutInflater inflater; 24 | private int markPosition = 0; 25 | 26 | public DataAdapter(Context context) { 27 | inflater = LayoutInflater.from(context); 28 | mList = new ArrayList(); 29 | } 30 | 31 | public void setData(List mList){ 32 | if(mList == null){ 33 | this.mList.clear(); 34 | }else{ 35 | this.mList = mList; 36 | } 37 | } 38 | 39 | @Override 40 | public int getCount() { 41 | return mList.size(); 42 | } 43 | 44 | @Override 45 | public Object getItem(int i) { 46 | return mList.get(i); 47 | } 48 | 49 | @Override 50 | public long getItemId(int i) { 51 | return i; 52 | } 53 | 54 | @Override 55 | public View getView(int position, View convertView, ViewGroup parent) { 56 | ViewHolder holder = null; 57 | if(convertView == null){ 58 | holder = new ViewHolder(); 59 | convertView = inflater.inflate(R.layout.item_menu, null); 60 | holder.mark = convertView.findViewById(R.id.v_line_vertical); 61 | holder.name = (TextView)convertView.findViewById(R.id.tv_name); 62 | convertView.setTag(holder); 63 | }else{ 64 | holder = (ViewHolder)convertView.getTag(); 65 | } 66 | 67 | String s = mList.get(position); 68 | 69 | holder.name.setText(s); 70 | if(position == markPosition){ 71 | holder.name.setEnabled(true); 72 | holder.mark.setVisibility(View.VISIBLE); 73 | }else{ 74 | holder.name.setEnabled(false); 75 | holder.mark.setVisibility(View.GONE); 76 | } 77 | 78 | return convertView; 79 | } 80 | 81 | class ViewHolder{ 82 | View mark; 83 | TextView name; 84 | } 85 | 86 | public void checked(int markPosition){ 87 | this.markPosition = markPosition; 88 | if(markPosition>=0 && markPosition < mList.size()){ 89 | notifyDataSetChanged(); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/microjixl/demo/DemoActivity.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * copyright(C)2014- 4 | * 5 | */ 6 | package com.microjixl.demo; 7 | 8 | import android.app.Activity; 9 | import android.app.Fragment; 10 | import android.app.FragmentManager; 11 | import android.app.FragmentTransaction; 12 | import android.os.Bundle; 13 | import android.view.View; 14 | import android.widget.ImageView; 15 | 16 | /** 17 | * @author jixiaolong 18 | */ 19 | public class DemoActivity extends Activity { 20 | private ImageView pic; 21 | private View choseSubject; 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_demo); 27 | initView(); 28 | } 29 | 30 | private void initView(){ 31 | choseSubject = findViewById(R.id.ll_select_subject); 32 | choseSubject.setOnClickListener(new View.OnClickListener() { 33 | @Override 34 | public void onClick(View view) { 35 | int[] location = new int[]{choseSubject.getLeft(),choseSubject.getTop()}; 36 | FragmentManager fm = getFragmentManager(); 37 | SelectFragment sf = SelectFragment.newInstance(location); 38 | FragmentTransaction ft = fm.beginTransaction(); 39 | ft.add(R.id.fl_subject_fragment,sf,"choiceSubject"); 40 | ft.addToBackStack(null); 41 | ft.commit(); 42 | } 43 | }); 44 | } 45 | 46 | @Override 47 | public void onBackPressed() { 48 | Fragment fg = getFragmentManager().findFragmentByTag("choiceSubject"); 49 | if(fg != null && ((SelectFragment)fg).onBackPressed()){ 50 | return; 51 | } 52 | super.onBackPressed(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/microjixl/demo/SelectFragment.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * copyright(C)2014- 4 | * 5 | */ 6 | package com.microjixl.demo; 7 | 8 | import android.app.Fragment; 9 | import android.os.Bundle; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.view.animation.Animation; 14 | import android.view.animation.AnimationUtils; 15 | import android.widget.AdapterView; 16 | import android.widget.ListView; 17 | import android.widget.RelativeLayout; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | import java.util.Random; 22 | 23 | /** 24 | * @author jixiaolong 25 | */ 26 | public class SelectFragment extends Fragment implements View.OnClickListener{ 27 | private ListView menuLv; 28 | private ListView subjectLv; 29 | private DataAdapter menuAdapter; 30 | private DataAdapter subjectAdapter; 31 | private View foldBtn; 32 | private View foldContent; 33 | private View lamp; 34 | private int[] location; 35 | 36 | public static SelectFragment newInstance(int [] location){ 37 | SelectFragment fg = new SelectFragment(); 38 | Bundle bundle = new Bundle(); 39 | bundle.putIntArray("LOCATION", location); 40 | fg.setArguments(bundle); 41 | return fg; 42 | } 43 | 44 | @Override 45 | public void onCreate(Bundle savedInstanceState) { 46 | super.onCreate(savedInstanceState); 47 | Bundle args = getArguments(); 48 | if (args != null) { 49 | int [] l = args.getIntArray("LOCATION"); 50 | if(l != null && l.length == 2)location = l; 51 | } 52 | } 53 | 54 | @Override 55 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 56 | View layout = inflater.inflate(R.layout.select_choice, container,false); 57 | initView(layout); 58 | return layout; 59 | } 60 | 61 | private void initView(View layout){ 62 | lamp = layout.findViewById(R.id.v_lamp); 63 | menuLv = (ListView) layout.findViewById(R.id.lv_menu); 64 | subjectLv = (ListView) layout.findViewById(R.id.lv_subject); 65 | foldBtn = layout.findViewById(R.id.ll_title_sp); 66 | foldContent = layout.findViewById(R.id.ll_lv_sp); 67 | RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams)foldBtn.getLayoutParams(); 68 | lp.leftMargin = location[0]; 69 | lp.topMargin = location[1]; 70 | foldBtn.setLayoutParams(lp); 71 | foldBtn.setOnClickListener(this); 72 | lamp.setOnClickListener(this); 73 | menuAdapter = new DataAdapter(getActivity().getBaseContext()); 74 | 75 | menuAdapter.setData(allocateData()); 76 | menuLv.setAdapter(menuAdapter); 77 | menuLv.setOnItemClickListener(new AdapterView.OnItemClickListener() { 78 | @Override 79 | public void onItemClick(AdapterView adapterView, View view, int i, long l) { 80 | menuAdapter.checked(i); 81 | subjectAdapter.setData(allocateSubject()); 82 | subjectAdapter.notifyDataSetChanged(); 83 | } 84 | }); 85 | subjectAdapter = new DataAdapter(getActivity().getBaseContext()); 86 | subjectAdapter.checked(-1); 87 | subjectAdapter.setData(allocateSubject()); 88 | subjectLv.setAdapter(subjectAdapter); 89 | } 90 | 91 | @Deprecated 92 | private List allocateSubject(){ 93 | //init test data 94 | List mList = new ArrayList(); 95 | String g = "语文"; 96 | mList.add(g); 97 | 98 | g = "数学"; 99 | mList.add(g); 100 | 101 | g = "英语"; 102 | mList.add(g); 103 | 104 | g = "化学"; 105 | mList.add(g); 106 | 107 | g = "政治"; 108 | mList.add(g); 109 | 110 | g = "物理"; 111 | mList.add(g); 112 | 113 | g = "英语"; 114 | mList.add(g); 115 | for(int i=0;i<3;i++){ 116 | Random random = new Random(); 117 | int d = random.nextInt(7-i); 118 | mList.remove(d); 119 | } 120 | return mList; 121 | } 122 | @Deprecated 123 | private List allocateData(){ 124 | //init test data 125 | List mList = new ArrayList(); 126 | String g = "小学"; 127 | mList.add(g); 128 | 129 | g = "初一"; 130 | mList.add(g); 131 | 132 | g = "初二"; 133 | mList.add(g); 134 | 135 | g = "初三"; 136 | mList.add(g); 137 | 138 | g = "高一"; 139 | mList.add(g); 140 | 141 | g = "高二"; 142 | mList.add(g); 143 | 144 | g = "高三"; 145 | mList.add(g); 146 | return mList; 147 | } 148 | 149 | @Override 150 | public void onClick(View view) { 151 | switch (view.getId()){ 152 | case R.id.ll_title_sp: 153 | case R.id.v_lamp: 154 | exitAnim(); 155 | break; 156 | 157 | } 158 | } 159 | 160 | @Override 161 | public void onResume() { 162 | super.onResume(); 163 | enterAnim(); 164 | } 165 | 166 | public boolean onBackPressed(){ 167 | exitAnim(); 168 | return true; 169 | } 170 | 171 | private void enterAnim(){ 172 | Animation turnOn = AnimationUtils.loadAnimation(getActivity().getBaseContext(),R.anim.fade_in); 173 | lamp.startAnimation(turnOn); 174 | 175 | Animation in = AnimationUtils.loadAnimation(getActivity().getBaseContext(),R.anim.popupwindow_slide_in_from_top); 176 | foldContent.startAnimation(in); 177 | } 178 | 179 | private void exitAnim(){ 180 | Animation turnOff = AnimationUtils.loadAnimation(getActivity().getBaseContext(),R.anim.fade_out); 181 | lamp.startAnimation(turnOff); 182 | Animation out = AnimationUtils.loadAnimation(getActivity().getBaseContext(),R.anim.popupwindow_slide_out_to_top); 183 | out.setAnimationListener(new Animation.AnimationListener() { 184 | @Override 185 | public void onAnimationStart(Animation animation) { 186 | 187 | } 188 | 189 | @Override 190 | public void onAnimationEnd(Animation animation) { 191 | lamp.setVisibility(View.INVISIBLE); 192 | foldContent.setVisibility(View.INVISIBLE); 193 | getFragmentManager().popBackStack(); 194 | } 195 | 196 | @Override 197 | public void onAnimationRepeat(Animation animation) { 198 | 199 | } 200 | }); 201 | foldContent.startAnimation(out); 202 | } 203 | 204 | @Override 205 | public void onPause() { 206 | super.onPause(); 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /src/main/res/anim/fade_in.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/main/res/anim/fade_out.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/main/res/anim/popupwindow_slide_in_from_top.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/main/res/anim/popupwindow_slide_out_to_top.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/main/res/drawable-hdpi/arrow_dark_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microjixl/LevelsChoice/a41cc12ff133881762ba0fd33cf9a952b154a14f/src/main/res/drawable-hdpi/arrow_dark_down.png -------------------------------------------------------------------------------- /src/main/res/drawable-hdpi/arrow_dark_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microjixl/LevelsChoice/a41cc12ff133881762ba0fd33cf9a952b154a14f/src/main/res/drawable-hdpi/arrow_dark_up.png -------------------------------------------------------------------------------- /src/main/res/drawable-hdpi/back_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microjixl/LevelsChoice/a41cc12ff133881762ba0fd33cf9a952b154a14f/src/main/res/drawable-hdpi/back_icon.png -------------------------------------------------------------------------------- /src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microjixl/LevelsChoice/a41cc12ff133881762ba0fd33cf9a952b154a14f/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microjixl/LevelsChoice/a41cc12ff133881762ba0fd33cf9a952b154a14f/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microjixl/LevelsChoice/a41cc12ff133881762ba0fd33cf9a952b154a14f/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microjixl/LevelsChoice/a41cc12ff133881762ba0fd33cf9a952b154a14f/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/main/res/drawable/round_stoke_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/res/drawable/select_menu_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/res/layout/activity_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 19 | 26 | 27 | 28 | 32 | 33 | -------------------------------------------------------------------------------- /src/main/res/layout/item_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 14 | 23 | -------------------------------------------------------------------------------- /src/main/res/layout/select_choice.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 12 | 21 | 28 | 29 | 30 | 38 | 46 | 56 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #fd7f52 4 | #f1f1ec 5 | #dadad5 6 | -------------------------------------------------------------------------------- /src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | microjixl 3 | 选择年级和科目 4 | 点击图片\n可编辑它 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 14 | 15 | 19 | 25 | 30 | 31 | --------------------------------------------------------------------------------