Android PopuWindow navigation chain-level Filtering

Source: Internet
Author: User

Android PopuWindow navigation chain-level Filtering

:



Code

Popu1_wwidget

package com.example.checklistview;import android.annotation.SuppressLint;import android.content.Context;import android.view.View;import android.view.ViewGroup.LayoutParams;import android.widget.PopupWindow;@SuppressLint("ViewConstructor")public class PopuWindowWidget{private static PopuWindowWidget popuWindow=null;private Context context;public PopuWindowWidget(Context context){this.context=context;}public static PopuWindowWidget getInstance(Context context){if(popuWindow==null){popuWindow=new PopuWindowWidget(context);}return popuWindow;}public void onCreatePopuWindow(View view,PopuWindowListener listener){PopupWindow pop=new PopupWindow(view,LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);pop.setOutsideTouchable(false);pop.setFocusable(false);pop.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.background_trans));listener.initialization(pop);}}
package com.example.checklistview;import android.widget.PopupWindow;public interface PopuWindowListener{void isShow(boolean isShow,String message);void initialization(PopupWindow popuWindow);void onClickItem(Object obj);}

PopuWindowView:

Package com. example. checklistview; import java. util. arrayList; import java. util. hashMap; import android. app. activity; import android. view. view; import android. view. view. onClickListener; import android. widget. button; import android. widget. listView; import android. widget. textView; import android. widget. toast; import com. example. checklistview. checkAdapter. nameOnClickListener; public class PopuWindowView implements NameOnClickListener {private static PopuWindowListener listener; private View view; private Activity activity; private TextView TV; private ListView listView_bar; private ListView listView_data; private ArrayList
 
  
Data = null; private ArrayList
  
   
Bar = null; private HashMap
   
    
> Map = new HashMap
    
     
> (); Private HashMap
     
      
CheckString = new HashMap
      
        (); Private CheckAdapter adapter_bar; private DataCheckAdapter adapter_data; private ViewHolder vhs; private TextView check_value; private Button sure; public static PopuWindowView getInstance (Activity activity Activity, PopuWindowListener popuWindowListener, int layout) {listener = popuWindowListener; return new PopuWindowView (activity, layout);} public PopuWindowView (Activity activity, int layout) {this. view = activity. getLayoutInflater (). inflate (layout, null); this. activity = activity; initialization ();} private void initialization () {// TODO Auto-generated method stubcheck_value = (TextView) view. findViewById (R. id. textView_check_value); sure = (Button) view. findViewById (R. id. sure); listView_bar = (ListView) view. findViewById (R. id. action_bar); listView_data = (ListView) view. findViewById (R. id. listview_data); initData (); adapter_bar = new CheckAdapter (activity, bar, this); adapter_data = new DataCheckAdapter (activity, map. get (0), this); listView_bar.setAdapter (adapter_bar); listView_data.setAdapter (adapter_data); sure. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO Auto-generated method stublistener. isShow (false, checkString. toString () ;}}) ;}private void initData () {// TODO Auto-generated method stubbar = new ArrayList
       
         (); CheckBean cb0 = new CheckBean (0, "release time", true); CheckBean cb1 = new CheckBean (1, "expected monthly salary", false ); checkBean cb2 = new CheckBean (2, "work experience", false); bar. add (cb0); bar. add (cb1); bar. add (cb2); data = new ArrayList
        
          (); CheckBean dcb0 = new CheckBean (0, "all", false); CheckBean dcb1 = new CheckBean (1, "today", false ); checkBean dcb2 = new CheckBean (2, "Last three days", false); CheckBean dcb3 = new CheckBean (3, "Last week", false ); checkBean dcb4 = new CheckBean (4, "last month", false); data. add (dcb0); data. add (dcb1); data. add (dcb2); data. add (dcb3); data. add (dcb4); map. put (0, data); data = new ArrayList
         
           (); CheckBean dcb01 = new CheckBean (0, "negotiable", false); CheckBean dcb11 = new CheckBean (1, "less than 3000 RMB", false ); checkBean dcb21 = new CheckBean (2, "3000-5000 yuan", false); CheckBean dcb31 = new CheckBean (3, "5000-8000 yuan", false); CheckBean dcb41 = new CheckBean (4, "8000-10000 RMB", false); CheckBean dcb51 = new CheckBean (5, "more than 10000 RMB", false); data. add (dcb01); data. add (dcb11); data. add (dcb21); data. add (dcb31); data. add (dcb41); data. add (dcb51); map. put (1, data); data = new ArrayList
          
            (); CheckBean dcb02 = new CheckBean (0, "unlimited", false); CheckBean dcb12 = new CheckBean (1, "no work experience", false ); checkBean dcb22 = new CheckBean (2, "less than 1 year", false); CheckBean dcb32 = new CheckBean (3, "1-3 years working experience", false ); checkBean dcb42 = new CheckBean (4, "3-5 years working experience", false); CheckBean dcb52 = new CheckBean (5, "5-10 years working experience", false ); checkBean dcb62 = new CheckBean (6, "more than 10 years working experience", false); data. add (dcb02); data. add (dcb12); data. add (dcb22); data. add (dcb32); data. add (dcb42); data. add (dcb52); data. add (dcb62); map. put (2, data); data = new ArrayList
           
             (); CheckBean dcb03 = new CheckBean (0, "all", false); CheckBean dcb13 = new CheckBean (1, "full time", false ); checkBean dcb23 = new CheckBean (2, "part-time", false); CheckBean dcb33 = new CheckBean (3, "intern", false); data. add (dcb03); data. add (dcb13); data. add (dcb23); data. add (dcb33); map. put (3, data);} public View getView () {return view;} @ Overridepublic void callbackPosition (int type, int position) {// TODO Auto-generated method stubif (type = 1) {for (int I = 0; I <adapter_bar.getList (). size (); I ++) {if (adapter_bar.getList (). get (I ). getId () = position) {adapter_bar.getList (). get (I ). setCheck (true);} else {adapter_bar.getList (). get (I ). setCheck (false) ;}} adapter_data.setList (map. get (position); adapter_bar.notifyDataSetChanged (); adapter_data.notifyDataSetChanged (); listView_data.post (new Runnable () {@ Overridepublic void run () {// TODO Auto-generated method stubfor (int I = 0; I <adapter_data.getList (). size (); I ++) {if (adapter_data.getList (). get (I ). isCheck () {listView_data.setSelectionFromTop (I, 0); return ;}} listView_data.setSelectionFromTop (0, 0) ;}});} else if (type = 2) {int index =-1; for (int I = 0; I <adapter_data.getList (). size (); I ++) {if (adapter_data.getList (). get (I ). getId () = position) {Toast. makeText (activity, ":" + I, 100 ). show (); adapter_data.getList (). get (I ). setCheck (true); index = I;} else {adapter_data.getList (). get (I ). setCheck (false) ;}} adapter_data.notifyDataSetChanged (); // int indexStart =-1; for (int I = 0; I <adapter_bar.getList (). size (); I ++) {if (adapter_bar.getList (). get (I ). isCheck () {indexStart = I; for (int j = 0; j <map. get (I ). size (); j ++) {if (j = index) {map. get (I ). get (index ). setCheck (true);} else {map. get (I ). get (j ). setCheck (false) ;}}}for (int I = 0; I <map. size (); I ++) {for (int j = 0; j <map. get (I ). size (); j ++) {if (map. get (I ). get (j ). isCheck () {checkString. put (adapter_bar.getList (). get (I ). getName (), map. get (I ). get (j ). getName () ;}} check_value.setText ("You selected:" + checkString. toString ());}}}
           
          
         
        
       
      
     
    
   
  
 


Http://download.csdn.net/detail/anddroid_lanyan/8229077 Resources




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.