I\'m developing a PopUp window for Android, and it\'s working, I added a EditText and a Button on that, when running on ADV this work properly, while running on device, when I f
I tried to run your code but everything works fine for me... Here is the test class I wrote :
public class TestActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn = (Button) findViewById(R.id.testBtn);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
showPopup();
}
});
}
private void showPopup()
{
PopupWindow window = new PopupWindow(this);
window.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
window.setTouchable(true);
window.setFocusable(true);
EditText text = new EditText(this);
text.setText("Touch it, it doesn't crash");
window.setContentView(text);
window.showAtLocation(text, Gravity.NO_GRAVITY, 30, 30);
}
}
main.xml :
Maybe you tried to run the popup code in the onCreate() function? If I do it, it throws the same Exception as yours, but it's normal since when onCreate() is called the activity is not fully initialized yet.
(I tried on a Galaxy Tab too, but without swype input)