我有两个类,一个适配器和一个活动,我有一个在适配器中显示的 dailog。当我尝试更改屏幕方向时出现错误。我尝试在我的活动中覆盖以下代码。但似乎没有任何效果
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.d(TAG, "configuration changed : " +newConfig);
}
下面是我的适配器代码
public AddressPopUpAdapter(Activity activity, Activity parent,
int resourceId, ArrayList<PopUpMenu> items, int renderer) {
super(activity, resourceId, items);
this.items = items;
this.renderer = renderer;
this.activity = activity;
this.parentActivity = parent;
popupMenuUtils = new PopupMenuUtils();
dialog = new Dialog(parentActivity);
}
public View getView(int position, View convertView, ViewGroup parent) {
popUpMenu = items.get(position);
Log.d(TAG, "location" + popUpMenu);
if (popUpMenu == null) {
return null;
}
Log.d(TAG, "location" + popUpMenu);
View view = convertView;
if (view == null) {
LayoutInflater layoutInflater = (LayoutInflater) (getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE));
view = layoutInflater.inflate(renderer, null);
}
final LinearLayout popupmain = (LinearLayout) view
.findViewById(R.id.popupmain);
popupmain.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
v.setEnabled(false);
performAction(v, activity);
}
});
if (position % 2 == 0) {
view.setBackgroundResource(R.drawable.listshape);
} else {
view.setBackgroundResource(R.drawable.favoritebody);
}
return view;
}
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();
}
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);
giving error here-----------> dialog.show();
} else {
Toast.makeText(parentActivity, R.string.nonavigationtolink,
Toast.LENGTH_SHORT).show();
}
this.activity.finish();
}
任何帮助表示赞赏。