我有两个类,一个适配器和一个活动,我的适配器中有一个对话框,amd iam 在我的活动中调用此适配器,当我在对话框启动时更改方向时,对话框被破坏。我试过了
<activity android:name=".activity.SearchAttraction" android:configChanges="keyboardHidden|orientation|screenLayout|screenSize" />
和
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
Noting is working, getting error at line `dialog.show();`
public void performAction(View v, Activity activity) {
Context myContext = v.getContext();
PopUpMenu popUpMenu = (PopUpMenu) v.getTag();
String result = popUpMenu.getMenuName();
if (result != null
&& result.equalsIgnoreCase(myContext.getResources().getString(
R.string.savecurrentlocation))) {
getCurrentLocation();
}
// For Manage Menu..
else if (result != null
&& result.equalsIgnoreCase(myContext.getResources().getString(
R.string.addnewplace))) {
AttractionData attractionData = new AttractionData();
createDiloag(attractionData,
activity.getResources().getString(R.string.addnewplace));
this.activity.finish();
}
// For About Us..
else if (result != null
&& result.equalsIgnoreCase(myContext.getResources().getString(
R.string.fromaddressbook))) {
Intent callIntent = new Intent(activity, ProfileActivity.class);
callIntent.putExtra("ProfileType", Constants.FROM_CONTATCS);
Log.d(TAG, "start to call On Activity Result Method : ");
parentActivity.startActivityForResult(callIntent, 100);
Log.d(TAG, "end to call On Activity Result Method : ");
this.activity.finish();
}
else if (result != null
&& result.equalsIgnoreCase(myContext.getResources().getString(
R.string.distancebetween))) {
AttractionService service = AttractionService
.getInstance(parentActivity.getApplicationContext());
ArrayList<AttractionData> allMenuSearchList = service
.getAllAttractions(true, Constants.field, Constants.order);
if (allMenuSearchList != null && !allMenuSearchList.isEmpty()) {
dialog.setContentView(R.layout.pickdestination);
ListView listPlace = (ListView) dialog
.findViewById(R.id.listPlace);
PlaceAdapter placeAdapter = new PlaceAdapter(parentActivity,
allMenuSearchList, R.layout.pickcity, dialog,
R.string.pickstartingpoint, null);
listPlace.setAdapter(placeAdapter);
dialog.show();
} else {
Toast.makeText(parentActivity, R.string.nonavigationtolink,
Toast.LENGTH_SHORT).show();
}
this.activity.finish();
}
这是我的日志
01-30 16:38:31.690: E/WindowManager(2791): android.view.WindowLeaked: Activity org.app.mycity.activity.ABActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@420c3948 that was originally added here
01-30 16:38:31.690: E/WindowManager(2791): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:412)
01-30 16:38:31.690: E/WindowManager(2791): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:312)
01-30 16:38:31.690: E/WindowManager(2791): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
01-30 16:38:31.690: E/WindowManager(2791): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
01-30 16:38:31.690: E/WindowManager(2791): at android.view.Window$LocalWindowManager.addView(Window.java:554)
01-30 16:38:31.690: E/WindowManager(2791): at android.app.Dialog.show(Dialog.java:277)
01-30 16:38:31.690: E/WindowManager(2791): at org.appright.myneighborhood.adaptor.AddressPopUpAdapter.performAction(AddressPopUpAdapter.java:169)
01-30 16:38:31.690: E/WindowManager(2791): at org.appright.myneighborhood.adaptor.AddressPopUpAdapter$1.onClick(AddressPopUpAdapter.java:93)
我很震惊,任何帮助表示赞赏。