2016-07-25 2 views
0

비트 맵 (setView의 요소)을 ImageView에 넣고 표시하려고합니다. 우리는 앱을 실행할 때 단순히 검은 색 배경의 오류가 없습니다.ImageView가 Android에서 비트 맵을 표시하지 않습니다.

public void setView(View element) { 
    mainView = element; 
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); 
    mainView.setVisibility(View.VISIBLE); 
    setContentView(element); 
    try { 
     rootLayout.addView(mainView,layoutParams); 
    }catch (Exception e){ 
     e.printStackTrace(); 
    } 
} 

이 우리의 에서 onCreate 우리는 유래에서이 문제에 대한 모든 제안 된 솔루션을 시도했지만 아무것도 우리를 위해 일하지

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    this.getInstance(); 
    this.authService = new AuthenticationService(); 
    this.authService.getInstance(this); 

    this.settingsManager = SettingsManager.getInstance(); 
    this.statusManager = StatusManager.getInstance(); 
    super.onCreate(savedInstanceState); 

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    getWindow().requestFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.activity_main); 

    mainView = findViewById(R.id.mainContentView); 
    loadingView = null; 
    mInflater = (LayoutInflater) AuthenticationService.getContext().getSystemService(LAYOUT_INFLATER_SERVICE); 
    vs = (View) mInflater.inflate(R.layout.activity_main, null); 
    rootLayout = (RelativeLayout) vs.findViewById(R.id.rootLayout); 

    AsyncCallRegistrationWS task = new AsyncCallRegistrationWS(); 
    task.execute(); 
} 

.

편집 : 우리는 다른 클래스에 setView()를 호출

public void createDisplay(){ 
    creationDate = DateTime.now(); 
    try { 
     if (state == DisplayState.Validated){ 
      if (entry != null && entry.template != null){ 
       DateTime now = DateTime.now(); 

       if (SettingsManager.getInstance().playlistTimeOffset != null){ 
        now.plus(SettingsManager.getInstance().playlistTimeOffset); 
       } 
      } 
      WindowManager wm = (WindowManager) AuthenticationService.getContext().getSystemService(Context.WINDOW_SERVICE); 
      android.view.Display screenDisplay = wm.getDefaultDisplay(); 
      int width = screenDisplay.getWidth(); 
      int height = screenDisplay.getHeight(); 

      View element = create(width,height); 
      if (element != null){ 
       StartUpActivity.getInstance().setView(element); 

       state = DisplayState.Created; 
       if (contentState == DisplayContentState.Unknown){ 
        contentState = DisplayContentState.Valid; 
       } 
      } else { 
       destroyDisplayOnFail(); 
      } 
     } 
    } catch (Exception e){ 
     Log.e(LOG_TAG, "Creating display failed. "+getLoggingContentIdentificationString()+" "+e.toString()); 
     destroyDisplayOnFail(); 
    } 
} 
+0

어디에서'setView' 메소드를 호출할까요? –

+0

@UttamPanchasara는 –

+0

의'setContentView (R.layout.activity_main)'과 팽창 된 레이아웃'vs = (View) mInflater.inflate (R.layout.activity_main, null); 모두 같습니까? –

답변

0

가 된 setContentView (요소)를 사용하지 마십시오; 액티비티 뷰를 대체하기 때문에 setView 메서드에서. rootLayout은 대체 된 R.layout.activity_main 뷰의 하위 뷰입니다. 그래서 당신은 아무것도 보지 못합니다.

+0

setContentView (element)를 잊어 버렸습니다. 삭제하는 것을 잊었습니다 –

+0

ImageView를 RelativeLayout에 추가하는 방법은 무엇입니까? 아무 것도 보여주지 않습니다 –

+0

rootLayout.invalidate();을 (를) 호출 해보십시오. 보기를 추가 한 후 – HooliGun

관련 문제