Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:01:39+00:00 2026-06-01T17:01:39+00:00

I am trying to create a icon and a short description below it. I

  • 0

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.

MyView.java

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);
    }

}

myview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/ic_launcher"
        />
    <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="my view"/>

</LinearLayout>

main.xml

<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" >
<sda.jk.MyView
        android:id="@+id/myView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >


    </sda.jk.MyView>
</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:01:42+00:00Added an answer on June 1, 2026 at 5:01 pm

    Step-1 First assign id to image view and text view in myview. xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <ImageView 
            android:id="@+id/myImage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/ic_launcher"
            />
        <TextView 
            android:id="@+id/myText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="my view"/>
    
    </LinearLayout>
    

    Step-2
    initialize your own view in oncreate method using

    MyView mv = (MyView)findViewById(R.id.myView1);
    

    step-3
    initilize image view and text view using findViewById method of your own view

    TextView textView = (TextView) mv.findViewById(R.id.myText);
            ImageView imageView = (ImageView) mv.findViewById(R.id.myImage);
    

    step-4
    set text to text view using setText method

    textView.setText("Sunil Kumar Sahoo");
    

    set background image to image view using

    imageView.setBackgroundResource(R.drawable.ic_launcher);
    

    Your oncreate method will be like the following (from step-2 to step-4)

    @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);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a custom loading/throbber icon for my app. I have an
I'm trying to create an application icon. I took a bunch of created *.ico
I'm trying to create a custom Android compound view, here is the code: <?xml
I'm trying to create an icon/widget (1 cell x 1 cell) that can be
I'm currently trying to create a ControlTemplate for the Button class in WPF, replacing
I am trying to create a simple Icon+Text ListView but it does not work.
I'm trying to create a custom accordion using jquery, have read through quite a
I'm trying to create a layout where I have a image and to the
I have a C#/WPF app. I am trying to create different versions that will
I am trying to create a button using CSS Gradients plus a icon that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.