pop.setTouchable(true);
pop.setBackgroundDrawable(new BitmapDrawable()); //
上面兩句代碼當點擊窗體外部popupwindow自動消失
我想讓popupwindow消失前執行一段代碼,比如改變字體等,那麼如何重寫dismiss()方法啊?
貼出部分源碼
public void popup() {//
inflater = (LayoutInflater)popupTest.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View listLayout = inflater.inflate(R.layout.listview, null);
listView= (ListView) listLayout.findViewById(android.R.id.list);
lvButtonAdapter listItemAdapter =
new lvButtonAdapter(this,list1, R.layout.item, new String[]{"text1","text2","ItemImage,RelativeLayout"}, new int[]{R.id.text1,R.id.text2,R.id.pup,R.id.re});
listView.setAdapter(listItemAdapter);
listView.setFocusable(true);
listView.setItemsCanFocus(true);
listView.setOnItemClickListener(new OnItemClickListener(){public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3) { edit1.getText().insert (edit1.getSelectionStart(),list1.get(arg2).get("text1").toString()); pop.dismiss(); }});//光標處插入文字
pop = new PopupWindow(listLayout, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
pop.setTouchable(true);
pop.setBackgroundDrawable(new BitmapDrawable()); //
pop.setFocusable(true);
}
window.setOnDismissListener()添加一個消失的監聽