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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:20:27+00:00 2026-06-02T21:20:27+00:00

I was trying out a ListActivity example from the net. I am having problem

  • 0

I was trying out a ListActivity example from the net. I am having problem using a custom list layout. Here is my code:

public class Test1Activity extends ListActivity {
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
            "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
            "Linux", "OS/2" };
    //ArrayAdapter<String> standard_adapter = new ArrayAdapter<String> (this,android.R.layout.simple_list_item_1, values);

    ArrayAdapter<String> my_adapter = new ArrayAdapter<String>(this, R.layout.mylistlayout, R.id.label,values);
    setListAdapter(my_adapter);
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    String item = (String) getListAdapter().getItem(position);
    Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
}}

onListItemClick is working fine when I use the standard adapter. But it doesn’t work when use my adapter. In fact I don’t even see any highlighting when I click on the list items. Why is this happening. Am I missing some code?

mylistlayout is a simple LinearLayout with a TextView(id label) and a Button(id button1).

<?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="fill_parent"
android:orientation="horizontal" >


<TextView
    android:id="@+id/label"
    android:layout_width="287dp"
    android:layout_height="wrap_content"
    android:text="items" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="32dp"
    android:padding="0dp"
    android:text="X" />

  • 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-02T21:20:29+00:00Added an answer on June 2, 2026 at 9:20 pm

    Try to add:

    android:focusable="false"
    

    to your Button in the xml layout.

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

Sidebar

Related Questions

I'm trying out ASP.NET MVC routing and have of course stumbled across a problem.
I am starting out on Android and trying to make a custom ListView layout.
Trying out the examples found on pleac.sf.net , I'm not able to get an
While trying out an experimental UINavigationController-based iPhone application, I ran into a problem when
Just trying out Hibernate (with Annotations) and I'm having problems with my mappings. I
I'm trying out the following query: SELECT A,B,C FROM table WHERE field LIKE 'query%'
I'm trying to display an image before the list in a listactivity. If I
I´m trying out entity framework included in VS2010 but ´ve hit a problem with
been trying to figure out why my code wont run in the new 4.0
iv been having trouble trying to set a listview from a json object from

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.