방향 변경을 처리하기 위해 다음 활동에 대한 코드 스 니펫을 사용했습니다. android의 방향 변경 작업
public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
{
base.OnConfigurationChanged (newConfig);
if (newConfig.Orientation == Android.Content.Res.Orientation.Landscape)
{
Console.WriteLine("landscape");
}
else if (newConfig.Orientation == Android.Content.Res.Orientation.Portrait)
{
Console.WriteLine("portrait");
}
}
[Activity (Label = "Activity",ConfigurationChanges = ConfigChanges.Orientation
| ConfigChanges.KeyboardHidden)]
및
나는Portrait
모드, 다음
Landscape mode
로 전환하고 다시
Portrait
모드로 다시 전환 시작합니다. 그래서 예상 출력 같아야
landscape
portrait
하지만 콘솔 출력 보여준다
landscape
landscape
portrait
즉 모두 실행 도착
경우 다른
Portrait
모드로
Landscape mode
에서 전환하는 경우.
왜 이런 일이 발생하는지 잘 모르겠습니다.
나는 절대적인 초보자이다. 모노 용 안드로이드, 그래서 어떤 도움을 주셨습니다.
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
int orientation = getResources().getConfiguration().orientation;
if(prev_orientation!=orientation){
prev_orientation = orientation;
if(orientation ==1){
//por
Toast.makeText(getApplicationContext(),"ort::pot"+orientation,Toast.LENGTH_LONG).show();
}else if(orientation ==2){
//land
Toast.makeText(getApplicationContext(),"ort::land"+orientation,Toast.LENGTH_LONG).show();
}
}
super.onConfigurationChanged(newConfig);
}
3) 활동의 manifeast 파일에서 선 아래 추가
이 시도 코드,하지만 동일한 출력 :( – GAMA
의 작업의 여부? 그것은 –