• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps setText and add...Listener to button in popup window

Ragoune

Lurker
Hi,

My question is short and simpel: Why are my Button and EditText not updated?

I have the following code to show a PopupWindow, afterwards I set the text of the EditText and add an onClickListener to the Button, but nothing happens (no text and no dismiss()):

Code:
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final PopupWindow window_navigate = new PopupWindow(inflater.inflate(R.layout.popup_navigate, null, false), LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
window_navigate.setFocusable(true);

View layout = inflater.inflate(R.layout.popup_navigate, null);

Button button_cancel = (Button)layout.findViewById(R.id.button_cancel);
button_cancel.setOnClickListener(new OnClickListener() {
	@Override
	public void onClick(View arg0) {
		window_navigate.dismiss();
		Log.d("----", "Dismiss");
	}
});
				
Location loc = locationmanager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (loc != null) {
	EditText edit_navigate_to = (EditText)layout.findViewById(R.id.edit_navigate_to);
	edit_navigate_to.setText(loc.getLatitude()+", "+loc.getLongitude());
	Log.d("----", "locAvailable");
}		
window_navigate.showAtLocation(findViewById(R.id.main), Gravity.CENTER, 0, 0);

Nothing happens, but in LogCat the debug messages are shown (so the code is executed).

I hope someone could help me out.

Ragoune
 
Back
Top Bottom