Android is similar to the implementation of QQ account login drop-down box (with source code), android drop-down box

Source: Internet
Author: User

Android is similar to the implementation of QQ account login drop-down box (with source code), android drop-down box


  • Some source code

// Set downArroImageView for popupWindow. setOnClickListener (new OnClickListener () {@ Override public void onClick (View arg0) {// defines popupWindow = new PopupWindow (MainActivity. this); // set the width of popupWindow. setWidth (inputEditText. getWidth (); // set the height of popupWindow. setHeight (200); // fill the popupWindow content with popupWindow. setContentView (listView); // click an area other than popupWindow to automatically close popupWindow. setOutsideTouchable (true); // set the position popupWindow in the pop-up window. showAsDropDown (inputEditText, 0, 0 );}});
// Initialize listviewprivate void initListView () {// TODO automatically generated method stub listView = new ListView (this); // sets the background color listView. setBackgroundResource (R. drawable. listview_background); // sets the delimiter to null listView. setDivider (null); // set the scroll bar to false listView. setVerticalScrollBarEnabled (false); listView. setAdapter (new MyListAdapter ());}
// MyListAdapterprivate class MyListAdapter extends BaseAdapter {@ Override public int getCount () {// return msgList, the method stub automatically generated by TODO. size () ;}@ Override public Object getItem (int arg0) {// return null, the method stub automatically generated by TODO;} @ Override public long getItemId (int arg0) {// return 0;} @ Override public View getView (final int arg0, View arg1, ViewGroup arg2) {// method stub ViewHolder houder automatically generated by TODO; if (arg1 = null) {arg1 = View. inflate (getApplicationContext (), R. layout. list_item, null); houder = new ViewHolder (); houder. deleteImageView = (ImageView) arg1.findViewById (R. id. delete); houder. TV _msgTextView = (TextView) arg1.findViewById (R. id. TV _list_item); arg1.setTag (houder);} else {houder = (ViewHolder) arg1.getTag ();} houder. TV _msgTextView.setText (msgList. get (arg0); houder. deleteImageView. setOnClickListener (new OnClickListener () {@ Override public void onClick (View v) {// Delete the corresponding entry msgList. remove (arg0); // refresh listview MyListAdapter. this. notifyDataSetChanged () ;}}); arg1.setOnClickListener (new OnClickListener () {@ Override public void onClick (View v) {// you can specify inputEditText in the input box. setText (msgList. get (arg0); // hide PopupWindow popupWindow. dismiss () ;}}); return arg1 ;}} private class ViewHolder {TextView TV _msgTextView; ImageView deleteImageView ;}

Source code download

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.