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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:14:49+00:00 2026-05-17T20:14:49+00:00

I have four tabs that hold four listviews, I want to set a background

  • 0

I have four tabs that hold four listviews, I want to set a background for each list view but whenever I try to add the background it puts the image in each cell of the listview instead of behind the list.

<?xml version="1.0" encoding="utf-8"?>

<TextView xmlns:android="http://schemas.android.com/apk/res/android"

android:background="@drawable/pre"

android:layout_width="fill_parent"
android:layout_height="fill_parent"

android:padding="10dp"

android:textSize="21sp">

</TextView>

I’ve realised that this is beacuse I’ve tried to add the background in a textview so it adds the image in each cell in the listview, so I have tried to add a linearlayout, listview and a imageview and put the background there but it force closes. I think this is becuse the tabhost uses main.xml to draw the main page and it conflicts, so I even tried to add the listview there still it nforce closes, it will only work if I have a textview only, howe can I add a background to each listview, below is the listview code;

public class prem extends ListActivity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    // Create an array of Strings, that will be put to our ListActivity
    String[] names = new String[] { "Pre"};
    ListView lv = getListView();    
    lv.setCacheColorHint(00000000);    
    lv.setAdapter(new ArrayAdapter<String>(this,
            R.layout.list_item, names));

}
  • 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-17T20:14:50+00:00Added an answer on May 17, 2026 at 8:14 pm

    Okay, your XML layout files are going to be used in the setContentView() method. You haven’t posted the code for your activity which includes the TabHost, but I’ll assume you’re using the default setContentView(R.layout.main);. If you’re NOT using setContentView() (in the case of your ListActivity), adding a ListView to an XML file isn’t going to change anything, because it’s never being used.

    You are correct in that you’re having the issue because you’re setting the background of the TextView. Since you’re using a ListActivity, you’ll need to set the ListView’s background using code. ListView is a subclass of View, so you can use the methods from the View class to set your background resource for the ListView.

    For example:

    ListView listView = getListView();
    
    //set background to color
    listView.setBackgroundColor(#FF888888);
    
    //set background to Drawable
    listView.setBackgroundDrawable(myDrawable);
    
    //set background to Resource
    listView.setBackgroundResouce(R.id.my_res_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created four tabs using tabhost, and placed four listviews in each like
I have created a tabbed view with four tabs and attached four listviews to
i have four radio buttons , and i want to set a text for
I have an iPhone app that has four tabs. On Tab 1 there is
I have an Android App that uses TabWidgets for displaying 4 Tabs. Each Tab
In my application,I have four tabs at the bottom.Each tab has multiple activities.In order
I'm new to stackoverflow and HTML/CSS/Javascript. I have four tabs and I want them
I have created four tabs with listview in each. I have been attempting to
I have four tabs in tabbar. Whenever I launch my application I need to
I have a TabControl that has four tabs: <TabControl> <TabItem><TextBox/></TabItem> <TabItem><UserControl/></TabItem> <TabItem><Label/></TabItem> <TabItem><Image/></TabItem> </TabControl>

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.