Android Wheelview (pulley assembly) use

Source: Internet
Author: User

Android Front-section component, fill-in form, select the entry style has a lot, wheelview scroll component as one of them, as shown in:

The first two people have used a lot, but I modified a bit, make a third, hoping to help everyone:

The code is as follows:

  EditText category =  (EditText)  findviewbyid (r.id.editcategory);  Category.setonclicklistener (Listener); private onclicklistener listener = new  Onclicklistener ()  {       @Override     public void  onclick (view v)  {         //  Create a session box          final AlertDialog dialog = new  Alertdialog.builder (                Set_accountactivity.this). Create ();         dialog.settitle ("Consumption Category:");          //  Create layouts           final linearlayout ll = new linearlayout (Set_accountActivity.this);        }  //  Set layout mode: Horizontal         ll.setorientation ( Linearlayout.horizontal);         final wheelview category1  = new wheelview (set_accountactivity.this);         Category1.setvisibleitems (5);       category1.setcyclic (True);         category1.setadapter (new arraywheeladapter<string> (CATEGORY_STR1));         final WheelView category2 = new  Wheelview (Set_accountactivity.this);         category2.setvisibleitems ( 5);         category2.setcyclic (True);         category2.setadapter (new arraywheeladapter<string> (category_str2[0));         //  CreateParameters         LinearLayout.LayoutParams lp1 = new  Linearlayout.layoutparams (               Layoutparams.wrap_content, layoutparams.wrap_content);         lp1.gravity = gravity.left;       //lp1.weight =  (float )  0.6;        linearlayout.layoutparams lp2 = new  linearlayout.layoutparams (               layoutparams.wrap_content, layoutparams.wrap_content);         lp2.weight =  (float)  0.6;        lp2.gravity  = Gravity.RIGHT;        lp2.leftMargin = 10;      &Nbsp;  ll.addview (CATEGORY1,&NBSP;LP1);         ll.addview ( CATEGORY2,&NBSP;LP2);        //  Add monitoring for Category1         category1.addchanginglistener (New onwheelchangedlistener ()  {            public void onchanged (WheelView wheel,  int oldValue,            int  NewValue)  {               Category2.setadapter (new arraywheeladapter<string> (                     category_str2[newvalue]);               category2.setcurrentitem (CATEGORY_STR2 [newvalue].length / 2); &Nbsp;           }          });        //  Create a OK button for the session         dialog.setbutton ("OK",  new dialoginterface.onclicklistener ()  {             @Override             public void onclick (Dialoginterface dialog, int which)  {               string cat1 =  category_str1[category1.getcurrentitem ()];               string cat2 = category_str2[category1.getcurrentitem () [ Category2.getcurrentitem ()];               category.settext (cat1 +  ">> "&NBSP;+&NBSP;CAT2";           dialog.dismiss ();            }          });         dialog.setbutton2 ("Cancel", new  Dialoginterface.onclicklistener ()  {           @ Override           public void onclick ( Dialoginterface dialog, int which)  {               dialog.dismiss ();             }         });        dialog.setview (ll);         dialog.show ();       }   }; }
 public String category_str1[] = new String[] {  "    Dining     ", "    transportation    ",        "     Shopping    ", "    Entertainment    ", "    medical    ", "     Education    ", "    home    ", "    investment    ",          "   Human  };  public string category   " _str2[][] = new string[][] {        new  string[] {  "   breakfast    , "   Lunch    ", "   dinner     ", "   supper    ", " Drink Fruit ",              "  Snacks   ",  "vegetable Ingredients",  "YOUYANJIANGCU",  "Other ..."  },        new&nbSp string[] {  "Subway",  "Bus",  "to play",  "refueling",  "Parking",  "Crossing the Bridge",  "fine",  "package Repair",              "Train",  "car model car Loan",  "auto Insurance",  "aviation ", " ship ", " bike ", " other ... "  },        new String[] {  "Clothing Shoes and Hats",  "Daily Necessities",   "Baby Supplies",  "digital Products",  "Makeup skincare",  "jewelry",  "tobacco and Wine",              "electrical",  "Furniture",  "books",  "Toys",  "Photographic print",  "other ..."  },        new String[] {  "See the movie",  "KTV",  "Online game games",  "Sports Fitness",  "bathing foot bath",  "tea Wine Coffee",              "Travel Holiday",  "show",  "Other ..."  },        new String[] {  "seek medical attention",  "buy medicine",  " Physical examination ", " test ", " medical equipment ", " other ... "  },        new string[] {  "Training",  "exam",  "books",  "tuition",  "tutor",  "tutorial ", " student loan ", " other ... "  },        new String[] {  "Beauty Salon",  "mobile phone",   "Broadband",  "mortgage",  "Hydro Gas",  "property",  "Accommodation Rental",              "premium",  "loan",  "material Building Materials",  "housekeeping Service",  "Express Postal",  "leaked",  "other ..."  },        new String[] {  "Securities Futures",  "insurance",  "Foreign exchange",  "contribution",  "Gold physical",  "calligraphy and painting Art",  "Investment Loan",              "Interest expense",  "other ..."  },        new String[] {  "Gift",  "items",  " Charitable donation ", " payment ", " other ... "  }, };
In addition, Wheelview classes are needed, which can be downloaded online (csdn) and added to your project

Android Wheelview (pulley assembly) use

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.