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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:08:46+00:00 2026-06-07T19:08:46+00:00

I have a ListView list that operates nicely. It’s set this way: <style name=Theme.Transparent

  • 0

I have a ListView list that operates nicely. It’s set this way:

<style name="Theme.Transparent" parent="android:Theme"> 
    <item name="android:windowIsTranslucent">true </item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">true</item>
</style>

This is my xml file:

<?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:padding="0dp" 
   android:background="@drawable/button_pressed"
   android:clickable="false"
   android:id="@+id/ListViewLayout" >

    <ImageView
        android:id="@+id/logo"
        android:layout_width="100dp"
        android:layout_height="50dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="5dp" />

    <TextView
        android:id="@+id/label"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30dp" >
    </TextView>
</LinearLayout> 

I also have a block of code which creates my ListView and handles my clicks:

public class RandomList extends ListActivity {
    static final String[] randomList = new String[] {"Name 1", "Name 2", "Name 3", "Logo"};

    @Override
    public void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setListAdapter(new RandomArrayAdapter(this, randomList));
    }

    protected void onListItemClick(ListView l, View v, int position, long id){
        //Get selected items
        Log.v("ListView l:", l.toString());
        Log.v("View v:", v.toString());
        Log.v("Position:", ""+position);
        Log.v("ID: ", ""+id);
        String selectedValue = (String) getListAdapter().getItem(position);
        Bundle bundle = new Bundle();
        bundle.putString("Name", selectedValue);
        Intent mIntent = new Intent();
        mIntent.putExtras(bundle);
        setResult(RESULT_OK, mIntent);
        finish();
    }
}

Now, with the ArrayAdapter et al, what happens is I get a list of items. As there are only five items, and due to the style I set for it, most of the screen is dimmed out (the original Activity), and only the list is centred. The problem is, I want to finish the Activity should someone click on the gray region outside of the list box. I cannot for the life of me figure out how.

I tried to implement an OnTouchListener, but ListView isn’t letting me do so and I can’t figure out how to call it for the LinearLayout container that surrounds the TextView. I’m fairly new to Android, so please dumb it down for me.

  • 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-07T19:08:48+00:00Added an answer on June 7, 2026 at 7:08 pm

    Create this xml layout and call it “list_layout.xml”:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="vertical"
         android:id="@+id/my_background"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
    
     <ListView android:id="@android:id/list"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"/>
     </LinearLayout>
    

    Then change your onCreate() to the following:

    public void onCreate (Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_layout);
    
        View background = findViewById(R.id.my_background);
        background.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 RamdomList.this.finish();
             }
         });
    
        setListAdapter(new RandomArrayAdapter(this, randomList));
    
    }
    

    I wrote this off the top of my head without running it, so you might fight a few things off but you get the concept.

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

Sidebar

Related Questions

It seems that android has enforced that a listview must have the name android:id=@android:id/list,
I have a listview that is loaded with a list of objects that contain
I have a list of items that are displayed using a ListView from a
I'd like to implement a ListView that will have a list of SelectedItems as
I have a list view with many rows and have it set so that
I have a ListView with a custom list adapter (that extends BaseAdapter). My list
Because my listView/List items have checkboxes I have the problem, that checkboxes are checked
I have a ListView with list items that have a Button on them. You
I have a list that contains names. I would like to create a listview
I assume this has a simple solution. I have a list that I want

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.