java - View not added to application -


i confused. action:

public class zoppenactivity extends activity {      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         final hostnamechecker c = new hostnamechecker();         c.execute(this);     } } 

and zoppen_main.xml:

<?xml version="1.0" encoding="utf-8"?> <view xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="#000"> </view> 

the preview (graphicallayout-tab) has black background, if debug application, there no black background. looks view never added application.

what did wrong?

you need use setcontentview in activity load view.so add oncreate.

public class zoppenactivity extends activity {      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.zoppen_main);         final hostnamechecker c = new hostnamechecker();         c.execute(this);     } } 

Comments

Popular posts from this blog

c# - Class in a list -

mysql - Django database model for my website -

ios - How to run a segue on itself OR another viewController -