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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:53:44+00:00 2026-06-04T10:53:44+00:00

1.Check condition only display public View getView(final int position, View convertView, ViewGroup parent) {

  • 0

1.Check condition only display

public View getView(final int position, View convertView, ViewGroup parent) {
    View vi = convertView;
    if (convertView == null)
        vi = inflater.inflate(R.layout.main_alllatestnewslist, parent,
                false);     
    ImageView imageview = (ImageView) vi
            .findViewById(R.id.image_alllatestnewstitle);
    imageview.setVisibility(View.INVISIBLE);
    TextView titletext = (TextView) vi
            .findViewById(R.id.text_particularlatestnewstitle);
    TextView categorytext = (TextView) vi
            .findViewById(R.id.text_newscategorytitle);
    TextView datetext = (TextView) vi.findViewById(R.id.text_newsdate);

    if (!imagepath[position].toString().equals("no picture")) {
        imageLoader.DisplayImage(imagepath[position], imageview);
        imageview.setVisibility(View.VISIBLE);          
        titletext.setWidth(460 - imageview.getWidth() - 5); <-- this line   
    } else {
        imageview.setVisibility(View.INVISIBLE);
        imageview.setImageDrawable(null);
    }
    titletext.setText(title[position].toString());
    categorytext.setText(category[position].toString());
    datetext.setText(date[position].toString());

    return vi;
}

The statement cannot be check when first view of the list and causing the textview stack with imageview. After scroll one or more times it only move to left.

How to go in this statement before display it?

2. set all items’ height in listview programmatically base on condition

RelativeLayout childlayout = (RelativeLayout)vi.findViewById(R.id.layout_childlist);

This is the layout for an item.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_childlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/list_bg"
android:minHeight="?android:attr/listPreferredItemHeight" >
<LinearLayout
    android:id="@+id/test"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_marginBottom="5px"
    android:layout_marginLeft="10px"
    android:layout_marginRight="10px"
    android:layout_marginTop="5px" >

    <ImageView
        android:id="@+id/image_alllatestnewstitle"
        android:layout_width="140px"
        android:layout_height="80px"
        android:scaleType="centerCrop" />
</LinearLayout>
....
</RelativeLayout>

For example, one of the item took 80px to display but the other items only took 40px. However, the other items will not wrap to 40px and wrap to 80px and make all the items has same height.

How to set the height for all items with difference height?

  • 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-04T10:53:45+00:00Added an answer on June 4, 2026 at 10:53 am

    Try imageview.setVisibility(View.GONE);

    INVISIBLE only hides the view while GONE ‘removes’ it

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

Sidebar

Related Questions

In my controller, I check a condition to see if the user is allowed
I use this condition to check if the value is alphanumeric values: $value =~
I need to find the MPMovieplayerController is playing or not with condition. Check the
check this out: template <class T> class Test: public T { public: void TestFunc()
Overview From time to time in jQuery I want to check a condition of
I have a form which I want to submit only if a condition is
I need an SQL statement that check if one condition is satisfied: SELECT *
I am trying to create a if then statement to only display something if
Please check the code below: objDDLTable = HttpContext.Current.Cache[TestSet] as Hashtable; if (objDDLTable == null)
I have a if condition for check value in textview but it still happen

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.