<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@mipmap/spinner"> <TextView android:id="@+id/et_list" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="@dimen/dp_12" android:layout_marginRight="@dimen/dp_12" android:gravity="center|start" /> <ImageView android:id="@+id/iv_arrow" android:layout_width="@dimen/dp_50" android:layout_height="match_parent" android:layout_alignParentRight="true" android:layout_marginLeft="@dimen/dp_100" android:padding="@dimen/dp_15" android:src="@drawable/arrow_down" /> </RelativeLayout>
package com.pdxx.xxpt.activity;import android.os.Build;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.support.v7.widget.ListPopupWindow;import android.view.Gravity;import android.view.View;import android.view.ViewGroup.LayoutParams;import android.widget.AdapterView;import android.widget.ArrayAdapter;import android.widget.ImageView;import android.widget.PopupWindow;import android.widget.TextView;import com.pdxx.xxpt.R;import com.pdxx.xxpt.utill.TimeUtil;import java.text.SimpleDateFormat;import java.util.Date;import java.util.Locale;import butterknife.BindView;import butterknife.But新疆司法警官学校terKnife;import butterknife.OnClick;public class SearchHighActivity extends AppCompatActivity implements View.OnClickListener { @BindView(R.id.et_list) TextView e董春辉tList盆腔炎是怎么引起的; @BindView(R.id.iv_arrow) ImageView ivArrow; private ListPopupWindow mPopup; private String[] mGoodArray = {"pencil", "potato", "peanut", "carrot", "cabbage", "cat"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tContentView(R.layout.activity_arch_high); 老子的名言名句 ButterKnife.bind(this); etList.tOnClickListener(this); mPopup = new ListPopupWindow(this); mPopup.tWidth(LayoutParams.WRAP_CONTENT); mPopup.tHeight(LayoutParams.WRAP_CONTENT); mPopup.tModal(true); } } @Override public void onClick(View v) { if (v.getId() == R.id.et_list) { tListPopu(v, mGoodArray, ivArrow, etList); } } private void tListPopu(View v, String[] strings, ImageView iv, TextView tv) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { mPopup.tDropDownGravity(Gravity.END); } ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item上上签斯琴高丽_1, strings); mPopup.tAdapter(adapter); mPopup.tAnchorView(v); mPopup.tOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { tv.tText(strings[position]); mPopup.dismiss(); } }); mPopup.tOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { iv.tImageResource(R.drawable.arrow_down); } }); mPopup.show(); ivArrow.tImageResource(R.drawable.arrow_up); }}
本文地址:https://blog.csdn.net/qq_26500807/article/details/110632933
本文发布于:2023-04-04 10:48:58,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/12bc17b0166208ada20761d829ffd02e.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:ListPopupWindow spinner.doc
本文 PDF 下载地址:ListPopupWindow spinner.pdf
留言与评论(共有 0 条评论) |