2014-12-08 53 views
-1

我有一個列表視圖與每個列表項目包含兩個Edittext視圖。我需要顯示一個圖像作爲信息窗口上的EditText當第一次打開屏幕,並刪除,如果用戶點擊屏幕上的任何地方。我不能明白我怎麼把這種形象略高於edittext.For參考我附上下面的屏幕:如何在列表視圖中將edit圖像顯示爲信息窗口?

enter image description here

請指導我如何可以放置圖像的第一列表項的EditText。

+0

你可以用'seterror'方法這一點。 – Shvet 2014-12-08 06:54:01

回答

0

您應該使用自定義對話框屏幕上的特定位置。每當用戶第一次打開對話框時都會顯示。

public static void shiftMessageDialog(Activity context, String message, 
      int theme) { 
     // custom dialog 
     final Dialog dialog = new Dialog(context); 
     dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
     dialog.setContentView(R.layout.shift_message_dialog); 
     RelativeLayout rv = (RelativeLayout) dialog.findViewById(R.id.rv); 



     // set the custom dialog components - text 

     TextView messageTxt = (TextView) dialog.findViewById(R.id.message_txt); 



     messageTxt 
       .setText("Remember to close up the store and we have training at 10am"); 


     dialog.show(); 
    } 
0

您可以使用PopupWindow來達到此目的。

代碼段

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
View popUpView = inflater.inflate(R.layout.pop_up, null, false); 
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), 
     R.drawable.select_dropdown); 
popupWindowProperty = new PopupWindow(popUpView, anchorView.getWidth(), 
     300, true);   
popupWindowProperty.setContentView(popUpView); 
popupWindowProperty.setBackgroundDrawable(new BitmapDrawable(getResources(), 
     bitmap)); 
popupWindowProperty.setOutsideTouchable(true); 
popupWindowProperty.setFocusable(true); 
popupWindowProperty.showAsDropDown(anchorView, 0, 0);