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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:44:42+00:00 2026-06-03T06:44:42+00:00

I have a problem now! I have custom ListView, there I have two TextView

  • 0

I have a problem now! I have custom ListView, there I have two TextView element. I want setVisibility(TextView.gone) for one TextView in ListView element. I don’t know how to do it

Write an example of how I can hide TextView ienter code heren all the items for ListView

ListView:

<ListView
            android:id="@+id/listResultAvia"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="left"
            android:layout_weight="1"
            android:background="#ffffff"
            android:cacheColorHint="#ffffff"
            android:drawingCacheQuality="auto" >

            <!-- Preview: listitem=@layout/item -->
        </ListView>

Custom item for ListVIew:

<?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="wrap_content"
    android:background="#fff" >
        <TextView
            android:id="@+id/textViewTimeResult"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/textViewTimeResult2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#000000"/>
    </LinearLayout>

Show me how I can hide textViewTimeResult2 in the onCreate.
If I write:

TextView test = (TextView) findById(R.id.textViewTimeResult2);
test.setVisibility(TextView.GONE);

My program crashed in start.

ADD:

I use answer below, but now I get empty ListView. How do I fix this?

  • 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-03T06:44:43+00:00Added an answer on June 3, 2026 at 6:44 am

    In your adapter you can try this code to hide the second textview.

    public View getView(int position, View convertView, ViewGroup parent){
           convertView = mInflater.inflate(R.layout.your_custom_list_layout, null);
        TextView textOne = (TextView)convertView.findViewById(R.id.txtOne);
        TextView textTwo = (TextView)convertView.findViewById(R.id.txtTwo);
    
        textTwo.setVisibility(View.GONE);
    
        return convertView;
    } 
    

    ADDED:
    you can add a boolean that toggles inside your onClick() then modify the getView();

        boolean hideTextTwo = false;
    
        onClick(View v){
          hideTextTwo = true;
          yourAdapter.notifyDatasetChanged();
    
        }
    
    
    public View getView(int position, View convertView, ViewGroup parent){
        convertView = mInflater.inflate(R.layout.your_custom_list_layout, null);
        TextView textOne = (TextView)convertView.findViewById(R.id.txtOne);
        TextView textTwo = (TextView)convertView.findViewById(R.id.txtTwo);
    
    if(hideTextTwo){
        textTwo.setVisibility(View.GONE);
    }
    
        return convertView;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem extracting data of the Oracle custom type from the database. One
I have encountered a problem twice now whereby a producer thread produces N work
I'm onto problem 245 now but have hit some problems. I've done some work
Every now and then I have a problem with SVN inside eclipse folder gets
I have come across quite a wired problem right now. I am using ASP.NET
I have a problem here. Right now I'm doing my Web Based Application, my
I have a problem that I had working in a test but now in
i'm making window component on Flash Professional CS4 and now i have 1 problem.
I am a beginner of Django. Now, I have a problem of getting templates.
I've been struggling with Zend_Navigation all weekend, and now I have another problem, which

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.