Encontre este tutorial en android el cual permite mostrar un popup window ver tutorial
Pero lo que yo hago es que se muestre mi popupwindow sin presionar algun boton esto es lo que tengo:
private PopupWindow popupWindow;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.conductor);
View rootView = getWindow().getDecorView().getRootView();
mostrar_popup(rootView);
}
private void mostrar_popup(View rootView) {
LayoutInflater layoutInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// inflate the custom popup layout
final View inflatedView = layoutInflater.inflate(R.layout.lista_alumnos, null,false);
// find the ListView in the popup layout
ListView lista_alumnos = (ListView)inflatedView.findViewById(R.id.lista_alumnos);
// get device size
Display display = getWindowManager().getDefaultDisplay();
final Point size = new Point();
display.getSize(size);
// set height depends on the device size
popupWindow = new PopupWindow(inflatedView, size.x - 50,size.y - 400, true );
// set a background drawable with rounders corners
popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.fondo_lista_alumnos));
// make it focusable to show the keyboard to enter in `EditText`
popupWindow.setFocusable(true);
// make it outside touchable to dismiss the popup window
popupWindow.setOutsideTouchable(true);
// show the popup at bottom of the screen and set some margin at bottom ie,
popupWindow.showAtLocation(rootView, Gravity.BOTTOM, 0,100); //aqui esta mi error
}
conductor.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" >
<fragment
android:id="@+id/map_conductor"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
de antemano les agradezco