Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Step-1</strong> First assign id to image view and text view in 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="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/myImage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_launcher" /&gt; &lt;TextView android:id="@+id/myText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="my view"/&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>Step-2</strong> initialize your own view in oncreate method using </p> <pre><code>MyView mv = (MyView)findViewById(R.id.myView1); </code></pre> <p><strong>step-3</strong> initilize image view and text view using findViewById method of your own view</p> <pre><code>TextView textView = (TextView) mv.findViewById(R.id.myText); ImageView imageView = (ImageView) mv.findViewById(R.id.myImage); </code></pre> <p><strong>step-4</strong> set text to text view using setText method</p> <pre><code>textView.setText("Sunil Kumar Sahoo"); </code></pre> <p>set background image to image view using </p> <pre><code>imageView.setBackgroundResource(R.drawable.ic_launcher); </code></pre> <p>Your oncreate method will be like the following (from step-2 to step-4)</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MyView mv = (MyView)findViewById(R.id.myView1); TextView textView = (TextView) mv.findViewById(R.id.myText); textView.setText("Sunil Kumar Sahoo"); ImageView imageView = (ImageView) mv.findViewById(R.id.myImage); imageView.setBackgroundResource(R.drawable.ic_launcher); } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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