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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:58:33+00:00 2026-06-15T23:58:33+00:00

I have a RelativeLayout with many textview like in this main.xml sample. main.xml <RelativeLayout

  • 0

I have a RelativeLayout with many textview like in this main.xml sample.

main.xml

<RelativeLayout  
xmlns:android="http://schemas.android.com/apk/res/android"  
android:layout_height="fill_parent"  
android:layout_width="fill_parent"
android:background="#000000"
android:id="@+id/RelativeLayout"
>  
<TextView 
    android:id="@+id/tv00"
    android:background="#ffffff"
    android:layout_height="wrap_content"  
    android:layout_width="wrap_content"
    android:clickable="true"></TextView>
<TextView  
    android:id="@+id/tv01"  
    android:layout_width="wrap_content"  
    android:layout_below="@+id/tv00"
    android:padding="5dp"
    android:clickable="true"></TextView> ...

...</RelativeLayout>  

I want in my activity.java to get access to the id of a textview I click. How to do that?
With onClickListener I can listen on RelativeLayout, but how to do it for a specific textview in that layout. Something with getid()?

activity.java

   RelativeLayout rv =(RelativeLayout)findViewById(R.id.RelativeLayout);
    rv.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v) {
        }
    });
  • 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-15T23:58:34+00:00Added an answer on June 15, 2026 at 11:58 pm

    As far as I know there is nothing like a “onChildClick” listener for RelativeLayout.
    You could iterate over your TextViews (using rv.getChildCount() and rv.getChildAt(i)) and add click listeners to the individual views…however, if your RelativeLayout just contains a list of TextViews you might want to consider using a ListView instead (and its setOnItemClickListener()).

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

Sidebar

Related Questions

I have this one layout: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android xmlns:tools=http://schemas.android.com/tools android:id=@+id/mainContainer android:layout_width=fill_parent android:layout_height=fill_parent > <TextView android:id=@+id/legend
I have a layout with a listView <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/testMain android:layout_width=fill_parent
I have such layout: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android xmlns:tools=http://schemas.android.com/tools android:layout_width=wrap_content android:layout_height=wrap_content android:orientation=horizontal> <TextView
In my foo_layout.xml file I have a subclassed RelativeLayout: <?xml version=1.0 encoding=utf-8?> <FrameLayout xmlns:android=http://schemas.android.com/apk/res/android
I have the following layout. <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=match_parent android:layout_height=wrap_content style=@style/list_item_bottom> <TextView android:id=@+id/list_item_name android:layout_width=match_parent
I have RelativeLayout with RelativeLayout title bar: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=wrap_content android:gravity=center_horizontal android:orientation=vertical >
I have the following Custom Component: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=@dimen/bottom_actionbar_item_height android:orientation=horizontal android:gravity=center> <Button android:id=@+id/btnLogin
I have a RelativeLayout with one child as <include another.xml> like this root.xml :
I have a dialog with this content: <RelativeLayout android:layout_width=wrap_content android:layout_height=wrap_content > <ScrollView android:layout_width=fill_parent android:layout_height=wrap_content
My problem is similar to what this person has posted: http://groups.google.com/group/android-developers/browse_thread/thread/216839d1c45cefa9/a1b9517d2064726b?show_docid=a1b9517d2064726b That is, my

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.