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 9070413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:41:04+00:00 2026-06-16T17:41:04+00:00

I have a view, inflated from custom layout, which contains a TextView . I

  • 0

I have a view, inflated from custom layout, which contains a TextView.
I tried to set TextView text both from xml via string resource and programmatically after layout inflating – I’m still getting only android.widget.RelativeLayout@4166f2d8 instead of normal text. What am I doing wrong?

Xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layers_list_item_root"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp" >

    <CheckBox
        android:id="@+id/layers_list_item_switch"
        blablabla... />

    <TextView
        android:id="@+id/layers_list_item_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left|center_vertical"
        android:layout_toLeftOf="@id/layers_list_item_switch"
        android:selectAllOnFocus="true"
        android:text="@string/layers_list_default_text"
        android:ellipsize="marquee"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:singleLine="true"
        android:scrollHorizontally="true"
        android:textColor="@android:color/black"
        android:textSize="16sp"
        android:textStyle="bold"
        android:typeface="serif"
        android:clickable="true" />

</RelativeLayout>

View inflating method:

public View createLayerListItem (String text) {
    View v = View.inflate(this, R.layout.layers_list_item, null);
    TextView text_view = (TextView) v.findViewById(R.id.layers_list_item_text);
    text_view.setText(text);
    return v;
}

And this views are used to fill some ListView:

ListView layers_list = (ListView)layers_dialog.findViewById(R.id.layers_list);
ArrayAdapter<View> adapter = new ArrayAdapter<View>(this, R.layout.layers_list_item, R.id.layers_list_item_text);

adapter.add(createLayerListItem("Test 1"));
adapter.add(createLayerListItem(""));
adapter.add(createLayerListItem("Very very very very very very long line"));

All my TextViews are wrong, showing android.widget.RelativeLayout@4166f2d8. I also tried to use default text from xml, not changing it from code at all – still I didn’t got my text from resource, only address.

  • 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-16T17:41:06+00:00Added an answer on June 16, 2026 at 5:41 pm

    Array adapter convert your views to string array because of this, it set textview text as its class name. So you should use like below,

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.layer_list_item, R.id.layers_list_item_text);
    
    adapter.add(createLayerListItem("Test 1"));
    adapter.add(createLayerListItem("Test 2"));
    adapter.add(createLayerListItem("Test 3"));
    
    
    public String createLayerListItem(String text) {
            View v = View.inflate(this, R.layout.layer_list_item, null);
            TextView text_view = (TextView) v
                    .findViewById(R.id.layers_list_item_text);
            text_view.setText(text);
            return text_view.getText().toString();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Tab that has a custom layout which contains a TextView .
I have view on which I defined a custom tagName. I need to be
i have view controller which contains a button which show the image library ,if
I have one custom ListView called AreasListView which I've included in the XML file.
I have a grid view which is populated using a custom ImageAdapter class extending
I have two layout files, a main one containing a custom view, and a
Trying to create a custom component that gets it's layout from an XML file
i have cursor which selects records from my CarProfile table and use custom adapter
I've created a Custom Component in layout/XML which has 2 TextViews and 2 Buttons.
I have a custom CursorAdapter which I'm using to inflate a custom item layout

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.