Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom linear layout
    primarykey
    data
    text
    <p>I'm trying to make my own LinearLayout to make it reusable and modular. first my code looked like this, which worked fine:</p> <pre><code>mLlHeader = (LinearLayout)view.findViewById(R.id.ll_header); mTvCrump = new TextView(mContext); mTvCrump.setText("&gt; "+((Item) mNavigationHistory.get(mNavigationHistory.size()-1)).getName()); mTvCrump.setId(mNavigationHistory.size()-1); mTvCrump.setClickable(true); mTvCrump.setOnClickListener(mBreadcrumpListener); mBreadcrump.add(mTvCrump); mLlHeader.addView(mTvCrump,mNavigationHistory.size()-1); </code></pre> <p>Now i want to make my own LinearLayout class like this:</p> <pre><code>public class Breadcrump extends LinearLayout { private List&lt;? super Item&gt; mNavigationHistory = new ArrayList&lt;Item&gt;(); private List&lt;TextView&gt; mElements = new ArrayList&lt;TextView&gt;(); public Breadcrump(Context context) { super(context); } public Breadcrump(Context context, AttributeSet attrs) { super(context, attrs); } public void addElement (String name) { } } </code></pre> <p>my xml looks like this:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/cell_selected" android:gravity="left" android:orientation="vertical" android:padding="5dp" &gt; &lt;com.client.views.Breadcrump android:id="@+id/ll_breadcrump" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>and use it like this:</p> <pre><code>mLlHeader = (Breadcrump)view.findViewById(R.id.ll_breadcrump); .... </code></pre> <p><strong>EDIT</strong></p> <p>i now added the namespace in the layout xml file where i use my custom view and a new Constructor in the view class with an attribute set. Now the app starts. But it displays only my custom view and the rest of the layout is white ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload