Wir wollen eine Bitmap (Element in SetView) in eine ImageView
setzen und anzeigen. Wir haben keine Fehler, es ist einfach ein schwarzer Hintergrund, wenn wir die App ausführen.ImageView zeigt keine Bitmap in 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();
}
}
das ist unser 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();
}
Wir haben versucht jede vorgeschlagene Lösung für dieses Problem auf Stackoverflow, aber nichts für uns gearbeitet.
EDIT:
Wir haben die setView() aufrufen, in einer anderen Klasse
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();
}
}
von wo Sie Ihre 'setView' Methode aufrufen ??? –
@UttamPanchasara editted –
Ihre 'setContentView (R.layout.activity_main)' und Ihr aufblähendes Layout 'vs = (View) mInflater.inflate (R.layout.activity_main, null);' beide sind gleich? –