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

  • Home
  • SEARCH
  • 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 6020105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:31:11+00:00 2026-05-23T03:31:11+00:00

I have a view with a TextView and a Custom View laid out in

  • 0

I have a view with a TextView and a Custom View laid out in a RelativeLayout. I am inflating the xml and I see both the TextView and CustomView rendered. Now I want to modify the text in the TextView depending on the actions of the user. How can I access the TextView from the view? I thought the following will work but I got a null –

mDisplay = (TextView)this.findViewById(R.id.displayBuffer);

The above works from inside the Activity but I really want to access it and modify it from the View.

EDIT: I did not post code because it might distract from the question. I am thinking accessing/modifying the TextView from inside a View should be a generic problem and nothing to do with my layout in specific. Having said that here is the layout —

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


            <TextView
                android:id="@+id/question"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textSize="30sp"
                android:text="ASDFASDF"
                android:textColor="#ffFFFFFF"   
                android:layout_gravity="center_vertical"
                android:paddingBottom="9dip"
                android:layout_marginLeft="3dip"
                android:layout_marginRight="2dip"/>

           <com.ac.gui.CustomView

            android:layout_below="@+id/question"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />

</RelativeLayout>

Thanks,
– P

  • 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-05-23T03:31:11+00:00Added an answer on May 23, 2026 at 3:31 am

    Assuming the two Views are in the same layout hierarchy:

    mDisplay = (TextView) this.getRootView().findViewById(R.id.displayBuffer);
    

    If you look at the docs, findViewById searches its child views, so you should go up the hierarchy before searching.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom view (an extension of a TextView) that I want to
I have a view that I want to add some custom drawing to. I
what I want to do in a view is have a textview and to
I have a ListView with a custom view rendered by an adapter. It contains
I have a half screen custom view and a TextView in my activity. <com.sted.test.mainView
I have list view with custom row layout (list_row.xml) that contains CheckBox element: <TableLayout
So I have a custom view set up in code (no XML layout defined
I have a custom view in my layout and I also have a TextView
I have list view with custom array adapter. I want to get items click
I have a custom component which consists of 2 text view and 4 toggle

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.