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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:37:02+00:00 2026-06-01T21:37:02+00:00

I have a list view with a custom baseadapter ,the code for the class

  • 0

I have a list view with a custom baseadapter ,the code for the class and the adapter is as follows

   public class LazyAdapter extends BaseAdapter {
    private Activity activity;
    private ArrayList<HashMap<String, String>> data;
    private static LayoutInflater inflater=null;
    public ImageLoader imageLoader; 


    public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)

            vi = inflater.inflate(R.layout.custom_row_view1, null);

        TextView title = (TextView)vi.findViewById(R.id.linkname); // merchnts name
        TextView artist = (TextView)vi.findViewById(R.id.imagename); // address
        //TextView duration = (TextView)vi.findViewById(R.id); // distance
       // ImageView thumb_image=(ImageView)vi.findViewById(R.id.mClogo); // logo

        HashMap<String, String> jsn = new HashMap<String, String>();
        jsn = data.get(position);

        // Setting all values in listview
       title.setText(jsn.get(Second.Li_nk));
       artist.setText(jsn.get(Second.Image_name));
        //duration.setText(song.get(CustomizedListView.KEY_DURATION));
        //imageLoader.DisplayImage(jsn.get(NearBy.KEY_THUMB_URL), thumb_image);
        return vi;
    }

}

and the class implementing it is as follows

    HashMap<String,String> map=new HashMap<String,String>();
        map.put("Id",String.valueOf(i));
        map.put(Li_nk,cutsec);
        map.put(Image_name,j4.getString("image_name"));
        mylist.add(map);

    }

    }
    catch(JSONException e){
        Log.e("loG_tag","Error parsing"+e.toString());
    }



     list=(ListView)findViewById(R.id.lv1);
     list.setOnItemClickListener(new AdapterView.OnItemClickListener(){

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                Toast.makeText(getApplicationContext(),
                        "Click ListItem Number " + position, Toast.LENGTH_LONG)
                        .show();

            }

        });
   LazyAdapter adapter = new LazyAdapter(this,mylist);

    list.setAdapter(adapter);
    list.setItemsCanFocus(false);



}

the layout containing the listview is

  <?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="#FFFFFF"
    android:orientation="vertical" >


    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/zsm" />


    <ListView
        android:id="@+id/lv1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:clickable="True"
         >

    </ListView>

</RelativeLayout>

and the code for the custom layout for the list is

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >




    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="70dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:clickable="True"
        android:focusable="false"


        android:background="@drawable/list_selector"
         >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="21dp"
            android:focusable="false"


            android:src="@drawable/merchntlogotitle" />


        <TextView
            android:id="@+id/imagename"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/imageView1"
            android:layout_marginLeft="15dp"
            android:layout_toRightOf="@+id/imageView1"
            android:clickable="false"
            android:focusable="false"

            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#000000" />


        <TextView
            android:id="@+id/linkname"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/imagename"
            android:layout_alignLeft="@+id/imagename"
            android:clickable="false"
            android:focusable="false"


            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000000" />

    </RelativeLayout>

</RelativeLayout>

Now setting the onitemclick listener gives no response ,what am I doing wrong ???
I have read plenty of xamples regarding this about setting focus false and others,what am I doing wrong??
Any help would be greatly apprreciated…

  • 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-01T21:37:04+00:00Added an answer on June 1, 2026 at 9:37 pm

    Remove the following from all the view items in your row’s layout, because this stuff is distracting ListView’s own item clicking events.

    android:clickable
    android:focusable
    

    for example:

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="70dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
    
        android:background="@drawable/list_selector"
         >
    
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="21dp"
    
            android:src="@drawable/merchntlogotitle" />
    
    
        <TextView
            android:id="@+id/imagename"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/imageView1"
            android:layout_marginLeft="15dp"
            android:layout_toRightOf="@+id/imageView1"
    
            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#000000" />
    
    
        <TextView
            android:id="@+id/linkname"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/imagename"
            android:layout_alignLeft="@+id/imagename"
    
            android:text="Medium Text"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#000000" />
    
    </RelativeLayout>
    

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

Sidebar

Related Questions

I have a ListView with a custom list adapter (that extends BaseAdapter). My list
I have created a custom Base Adapter class, to populate a list view with
I have implemented a custom list view which looks like the twitter timeline. adapter
We have created custom listview by using the Base adapter. List view contains Text
I have a custom list view implemented with Baseadapter. My dataset includes a string
I have used a custom array adapter to populate my list view.The problem i
I have an extended from BaseAdapter class which used as a custom Adapter for
I have Custom List to display image with it's name like below... public class
I have list view with custom array adapter. I want to get items click
I have a custom list view that is getting data from server and changing

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.