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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:26:32+00:00 2026-05-29T16:26:32+00:00

I have a Custom Listview but i’m running into a weird issue when I

  • 0

I have a Custom Listview but i’m running into a weird issue when I click one item: it only responds when I click on the text itself, it doesn’t work on the whole “rectangle”

this is my listelement.xml

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


<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:paddingLeft="6dip"
android:minHeight="20dip"
/>

and this is the java code:

public class TabFragment5 extends ListFragment {
/** (non-Javadoc)
 * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
 */
String[] month ={
           "January                     ", 
           "February", 
           "March", 
           "April",
           "May", 
           "June", 
           "July", 
           "August",
           "September", 
           "October", 
           "November", 
           "December"
         };



         @Override
         public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          ListAdapter myListAdapter = new ArrayAdapter<String>(
            getActivity(),
            R.layout.listelement,
            month);
          setListAdapter(myListAdapter);
         }

         @Override
         public View onCreateView(LayoutInflater inflater, ViewGroup container,
           Bundle savedInstanceState) {
          return inflater.inflate(R.layout.tab_frag5_layout, container, false);
         }

         @Override
         public void onListItemClick(ListView l, View v, int position, long id) {
          // TODO Auto-generated method stub
          Toast.makeText(
            getActivity(), 
            getListView().getItemAtPosition(position).toString(), 
            Toast.LENGTH_LONG).show();
         }
        }

Nevermind the silly program, i’m just running a tutorial for now. Any hints on how to make it work on the whole list item rectangle? Thanks

  • 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-29T16:26:33+00:00Added an answer on May 29, 2026 at 4:26 pm

    ListFragment already has a ListView in it, so you may not need to inflate a layout from onCreateView unless you are making a custom layout that has a ListView inside it. I imagine your problem is in your layout for tab_frag5_layout. Whatever you are wrapping the ListView in is probably shrinking the width of the ListView.

    Combining your onCreate and onCreateView into a onActivityCreated implementation worked for me.

    @Override
    public void onActivityCreated(Bundle savedInstanceState)
    {          
      super.onActivityCreated(savedInstanceState);
    
      ListAdapter myListAdapter = new ArrayAdapter<String>(
            getActivity(),
            R.layout.listelement,
            month);
      setListAdapter(myListAdapter);
    

    }

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

Sidebar

Related Questions

I currently have a custom listview with two rows of text in each item,
I have two ItemsControls, one a ListView, and one a custom control I am
We have created custom listview by using the Base adapter. List view contains Text
I have one listview.which contain one image ,text and one button .i had creted
I have made custom .xml layout for ListView. Now it looks: But it isn't
I have one custom ListView which contains one ImageView and one TextView, and I
I have a custom listview in which one textview and one checked box is
I have a listView with custom objects defined by the xml-layout below. I want
I have a ListView with a custom Adapter that extends ArrayAdapter. It's a ArrayAdapter
I have trouble getting a custom ObjectDataSource for an asp:ListView control to work. I

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.