Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing the Custom View in android
    primarykey
    data
    text
    <p>I am trying to create a icon and a short description below it. I have created a customised View class with a ImageView and a TextView and i integrated it with my xml file, now the imageView and the default text appears in the screen,i don't know how to change the text content of the textview or the source of the imageview.</p> <p>MyView.java</p> <pre><code>package sda.jk; public class MyView extends LinearLayout{ public MyView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub LayoutInflater li=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v= li.inflate(R.layout.myview, this); } } </code></pre> <p>myview.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_launcher" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="my view"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>main.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/sda.jk" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;sda.jk.MyView android:id="@+id/myView1" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/sda.jk.MyView&gt; &lt;/LinearLayout&gt; </code></pre>
    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.
    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