opupwindowはactivityを開いたときに直接表示されます

1203 ワード

 onCreate() popupwindow activity popupwindow , :
@Override
	public void onAttachedToWindow() {
		// TODO Auto-generated method stub
		super.onAttachedToWindow();
                // popupwindow 
		showPopupWindow(); 
	
	}

public void showPopupWindow() {
		layout = View.inflate(this, R.layout.widget_main, null);
		popupWindow = new PopupWindow(layout,	LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
		popupWindow.setAnimationStyle(R.style.PopupAnimation);
		//  back 
		ColorDrawable dw = new ColorDrawable(-00000);
		popupWindow.setBackgroundDrawable(dw);
		View view = findViewById(R.id.layout_main);
		popupWindow.showAtLocation(view,	Gravity.CENTER | Gravity.CENTER, 0, 0);
		popupWindow.update();
	}

もう一つは私が他の人から見たことを実践したことがないことです.
private Handler mHandler = new Handler();  
  
@Override  
protected void onCreate(Bundle savedInstanceState) {  
    // TODO Auto-generated method stub  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.main);  
    mHandler.postDelayed(mRunnable, 500);  
}  
      
private Runnable mRunnable = new Runnable() {  
    public void run() {  
    //  PopupWindow   
    }  
};