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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:02:33+00:00 2026-05-25T20:02:33+00:00

I am trying to set background for my List view . I have taken

  • 0

I am trying to set background for my List view . I have taken a image from the drawable and set it as background to the layout file then it is giving the result as following screen shotscreen with background

and when i just remove the background am getting the thing which i required but no background.
and screen shot is screen without background
Is there is any other Syntax to set background for ListView.

And my Code for layout is

    <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"

      >


    <TextView android:text="@+id/TextView01" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/label"
            android:textColor="#FF0000"
            android:textSize="30px"></TextView>
      </LinearLayout>




And my java code and that is 

String[] names = new String[] { "India", "Malaysia" };
        // Use your own layout and point the adapter to the UI elements which
        // contains the label
        this.setListAdapter(new ArrayAdapter<String>(this, R.layout.screen3,
                R.id.label, names));
    }

    @Override

    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        // Get the item that was clicked
        Object o = this.getListAdapter().getItem(position);
        String keyword = o.toString();
        if(keyword.equals("India"))
        {

            Intent ima1=new Intent(screen3.this,new21.class);

            startActivity(ima1);

        }
        else
        {
            Intent ima2=new Intent(screen3.this,new22.class);
            startActivity(ima2);
        }

        Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG)
                .show();

    }

And lastly i need is I want the background image with proper listview showing one listitem after another. Thanks in advance
}

  • 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-25T20:02:33+00:00Added an answer on May 25, 2026 at 8:02 pm

    Try this code, Instead of extending ListActivity you can set layout that contains List View and separate layout for contents of List View.

    Java Code :

    public class Table_Layout extends Activity {
    
      ListView list_view;
      @Override
       public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.table_layout);
          list_view=(ListView)findViewById(R.id.list_view);
          String[] names = new String[] { "India", "Malaysia" };
          list_view.setAdapter(new ArrayAdapter<String>(this, R.layout.screen3,R.id.label, names));
        }
    }
    

    Main XML that contains List View :table_layout.xml

    <?xml version="1.0" encoding="utf-8"?>
     <RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:background="@drawable/uploading">
        
        <ListView   android:layout_width="fill_parent" android:layout_height="fill_parent" 
                    android:id="@+id/list_view"  
        />
    

    Then Contents of List View :screen3.xml

    <?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"
      >
    <TextView android:text="@+id/TextView01" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/label"
            android:textColor="#FF0000"
            android:textSize="30px"></TextView>
      </LinearLayout>
    

    Set you Background for the table_layout.xml so that it will applied for entire List View as you expected.

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

Sidebar

Related Questions

I'm trying to set the background image of a view based on a passed
I am trying to set the background image of my view controller based on
I'm trying to set an image as a background image. From what I've read
I'm trying to set the background image of canvas using canvas.setBackgroundImage(image); How can i
I'm trying to set an image as background of the Sherlock Action Bar, but
I'm trying to keep my HTML very simple. I have a set list which
Hi I am fetching data for List View from web and want to set
I am trying to set alternate colors of an entry in a list view.
I'm Trying to set the background image (which is located in the same folder
I'm trying to set the background color of a UIImageView with this (It should

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.