android - Add layout resource programmatically -


"postprint" itemprop = "text">

I have a custom layout called "debug.xml" in the folder called "layout /" as a predefined program Activity_man, called Center_leoutout to add The layout in XML is "Debug.xml" something like this:

  . & Lt; LinearLayout Android: layout_width = "match_parent" Android: layout_height = "wrap_content" & gt; & Lt; EditText android: id = "@ + id / commandEditText" Android: layout_width = "0dp" Android: layout_height = "50dp" Android: layout_weight = "1" android: gravity = "center_vertical" Android: inputType = "text" / & gt ; & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt;  

I want to add this "debug_layout" a centerLayout are:

  LinearLayout centerLayout = (LinearLayout) findViewById (R.id.center_layout); LinearLayout debugLayout = (Linear Loyalty) FindBuyId (R.id.debug_layout); CenterLayout.addView (debugLayout);  

But it "center layout. Adwu (Dibgleaut) encounters the null pointer Akspeshn on"; So it seems that debug_layout has not been started or something else can help me?

What rolled your heart you sure? If not, what you try to do:

  LinearLayout centerLayout = (LinearLayout) findViewById (R.id.center_layout); Linear Line Debgleout = Meet-Stay Inflator () Flowers (R. Layout. Debug, Center Layout, False); CenterLayout.addView (debugLayout);  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -