日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

PopupWindow的使用

發布時間:2025/6/17 编程问答 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PopupWindow的使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

想要彈出內容就可以考慮使用懸浮窗

布局 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/rl_root"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context=".LoginActivity" ><com.handmark.pulltorefresh.library.PullToRefreshListViewandroid:id="@+id/lv_list"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_weight="1"android:background="#fff" /><Viewandroid:id="@+id/viewHolder"android:layout_width="match_parent"android:layout_height="53dp"android:visibility="gone" /> </LinearLayout>

 代碼

lv_list.setOnItemLongClickListener(new OnItemLongClickListener() {@Overridepublic boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {Toast.makeText(getApplicationContext(), "長按", 0).show();//開啟編輯模式startEditModel();if (position > 0) {position -= 1;}adapter.toggleSelect(view, position);return true;}});}private boolean isEditModel;private int seletedCount;/*** 開啟編輯模式*/private void startEditModel() {//listview需要刷新isEditModel = true;adapter.notifyDataSetChanged();//修改actionbaruploadMenuItem.setVisible(false);downloadMenuItem.setVisible(false);moreMenuItem.setVisible(false);selectMenuItem.setVisible(true);actionBar.setDisplayHomeAsUpEnabled(true);actionBar.setTitle(String.format("已選定%d個", seletedCount));//顯示底部的popupwindows //當在最 底部時會覆蓋條目,可以在下面弄個view,讓他顯示showBottomPopupWindow();//listview上移viewHolder.setVisibility(0);}/*** 結束編輯模式*/private void stopEditModel() {//listview需要刷新isEditModel = false;adapter.notifyDataSetChanged();//修改actionbaruploadMenuItem.setVisible(true);downloadMenuItem.setVisible(true);moreMenuItem.setVisible(true);selectMenuItem.setVisible(false);actionBar.setTitle("黑馬網盤");//返回按鈕的處理if ("/".equals(curPath)) {actionBar.setDisplayHomeAsUpEnabled(false);}//隱藏popupwindowsbottomPopupWindow.dismiss();//listview還原viewHolder.setVisibility(8);//還原entryWrapper的選中狀態for (EntryWrapper entryWrapper : contents) {entryWrapper.isCheck = false;}seletedCount = 0;}private void showBottomPopupWindow() {if (bottomPopupWindow == null) {View contentView = View.inflate(MainActivity.this, R.layout.bottom_edit_pop, null);int width = ViewGroup.LayoutParams.FILL_PARENT;int height = ViewGroup.LayoutParams.WRAP_CONTENT;bottomPopupWindow = new PopupWindow(contentView, width, height);contentView.findViewById(R.id.DeleteBtn).setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {List<EntryWrapper> selectedEntryWrappers = new ArrayList<EntryWrapper>();for (EntryWrapper info : contents) {if (info.isCheck) {selectedEntryWrappers.add(info);}}StringBuffer sb = new StringBuffer();//遍歷輸出for (EntryWrapper entryWrapper : selectedEntryWrappers) {sb.append(entryWrapper.entry.fileName()).append(" ");}System.out.println(sb.toString());}});}bottomPopupWindow.showAtLocation(rl_root, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);}

  

轉載于:https://www.cnblogs.com/sixrain/p/5276612.html

總結

以上是生活随笔為你收集整理的PopupWindow的使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。