2012-03-28 9 views
5

次のコードで、画面の左端にListPopupWindowを表示することができました。Display ListPopupWindowを画面の最も左に表示する

@Override 
public View onCreateActionView() { 
    LayoutInflater layoutInflater = LayoutInflater.from(mContext); 

    final View actionItem = layoutInflater.inflate(R.layout.list_table_view_action_provider, null); 

    final ImageButton button = (ImageButton) actionItem.findViewById(R.id.button); 
    button.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      mListPopupWindow = new ListPopupWindow(mContext); 
      mListPopupWindow.setAnchorView(actionItem); 
      mListPopupWindow.setAdapter(mAdapter); 
      mListPopupWindow.setModal(true); 
      mListPopupWindow.setContentWidth(150); 

      // Display mListPopupWindow on most left of the screen 
      mListPopupWindow.setHorizontalOffset(-1000); 


      mListPopupWindow.setOnItemClickListener(ListTableViewActionProvider.this); 

      mListPopupWindow.show(); 
      mListPopupWindow.setOnDismissListener(ListTableViewActionProvider.this); 
     } 
    }); 

    return actionItem; 
} 

"mListPopupWindow.setHorizo​​ntalOffset(-1000);"あまりにも悪いです。 他にも解決策はありますか?ここ

+1

をアンカーとして、および0 オフセットか、またPopupWindowを使用して、としてx、yを与えることができると活性の最も外側のレイアウト/のViewGroupを有する試します0 – Varun

+1

ホームアイコンにアンカーできますか? – dadachi

+1

ホームアイコンにアンカーし、 'findViewById(android.R.id.home)'を使ってビューを取得することができます。ポップアップは画面の左端とは同じになりません。自宅のアイコンは左に余裕を持っています(「上」のアフォーダンスの矢印のためのスペースを確保するため)。 – Karakuri

答えて

-1

はListPopupWindow例であり、

 View menuItemView = getActivity().findViewById(R.id.menu_filter); 
     ListPopupWindow popup  = new ListPopupWindow(getActivity()); 

     popup.setHorizontalOffset(-200); 
     popup.setVerticalOffset(-100); 

     popup.setAnchorView(menuItemView); 
     popup.setWidth(400); 
     popup.setModal(true); 
     popup.setHeight(ListPopupWindow.WRAP_CONTENT); 

     ListAdapter adapter = new MyAdapter(getActivity()); 
     popup.setAdapter(adapter); 

     popup.show(); 
関連する問題