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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:58:29+00:00 2026-05-28T01:58:29+00:00

Following shows the code and screenshot for displaying data in listview containing 3 textview

  • 0

Following shows the code and screenshot for displaying data in listview containing 3 textview.

I tried the following code in getView() method of Adapter class to give background image to alternate rows i.e. row no. 0,2,4,etc.

When I try to implement this, I get the output as shown in screen-shots i.e. row are not getting effected appropriately.

Also, refer to below xml in which alignTop and alignBottom parameters are used, still on Index button click, 2nd and 3rd textview are not getting background color appropriately.

EDIT – If I use colour instead of image for background, it works well for all cases except for Index button.

if (count % 2 == 0) {

    try {

        InputStream is = ctx.getAssets().open("cellbg.png");
        Drawable d = Drawable.createFromStream(is, "cellbg");
        holder.txtFirst.setBackgroundDrawable(d);
        holder.txtSecond.setBackgroundDrawable(d);
        holder.txtThird.setBackgroundDrawable(d);
        Log.v("count=", "" + (count++));

    } catch (Exception e) {
        throw new Error(" exception in TableListAdapter " + e.getMessage());
    }
} else {
    Log.v("else count==", "" + (count++));
}      

list structure(xml)

<TextView
        android:id="@+id/FirstText"
        android:layout_width="80dp"
        android:layout_height="wrap_content"/>
    
    <TextView
        android:id="@+id/SecondText"
        android:layout_width="55dp"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/FirstText"
        android:layout_alignBottom="@+id/FirstText"/>
    
    <TextView
        android:id="@+id/ThirdText"
        android:layout_width="40dp"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/FirstText"
        android:layout_alignBottom="@+id/FirstText"/>

1st screen shows the list structure at the time of application launch, where by default, Gainers button is pressed.

2nd shows an instance of pressing Index button.

3rd shows an instance of pressing Gainers button again after pressing index button.

4th shows the layout when List item is clicked.

What am I doing wrong?

ANY HELP WILL BE LIFE-SAVER !!!

screen

  • 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-28T01:58:30+00:00Added an answer on May 28, 2026 at 1:58 am

    Couple of things…. not sure what the different buttons are and what they do, but it should not matter…

    You should set the background also when (count % 2 != 0) because the views can be reused in the list, so better be safe.

    Also, instead of setting the background for the different TextViews individually, why not set it only for the ViewGroup that contains all those TextViews (I imagine a LinearLayout or something like that) ?

    Just to double check, count is the argument you get when getView gets called ?
    Maybe you could post a bit more code of your getView method, that would probably help (to get a better answer).

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

Sidebar

Related Questions

The following code shows a button that allows you to select a file (should
The following piece of code shows an Insert table dialog: Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable];
Consider the following code which shows compile time error : #include <stdio.h> int main(int
I have the following code that shows either a bug or a misunderstanding on
In the following code, the first log statement shows a decimal as expected, but
the following code shows invalid qualifier when executed Dim strs As String Dim insStr
The following code shows me that cacheasbitmap is turning on and off like it
The following NewLISP code shows me the file attributes of files under Win32. However,
I am using the following code to take a screenshot of a TableLayout. I
Referring to below screenshot, ListView consists of 3 TextView . Depending on the value

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.