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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:44:04+00:00 2026-06-15T06:44:04+00:00

I have a custom listView.xml having a listView as. <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android

  • 0

I have a custom listView.xml having a listView as.

    <?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="match_parent"
    android:background="@null" >

    <ListView
        android:id="@+id/searchList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtSearchFor"
        android:background="@color/Black" >
    </ListView>

</RelativeLayout>

this listview contains an ImageView, 2 TextViews and a RatingBar (item_list.XML) as given below.

    <?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="match_parent" >
    <RelativeLayout
        android:id="@+id/rel_SearchLayout01"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >

        <ImageView
            android:id="@+id/img_searchBookCoverPhoto"
            android:layout_width="70dp"
            android:layout_height="100dp"
            android:layout_margin="5dp"
            android:background="@drawable/rounded_image_borders"
            android:focusable="false"
            android:src="@drawable/book1" />

        <TextView
            android:id="@+id/txt_searchBookTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/img_searchBookCoverPhoto"
            android:layout_marginTop="10dp"
            android:layout_toRightOf="@+id/img_searchBookCoverPhoto"
            android:focusable="false"
            android:text="The Basic Doctrine Of Islam"
            android:textColor="@color/White"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/txt_searchAutherName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/txt_searchBookTitle"
            android:layout_marginTop="2dp"
            android:layout_toRightOf="@+id/img_searchBookCoverPhoto"
            android:focusable="false"
            android:text="By: Andrew J Newman"
            android:textColor="@color/SkyBlue"
            android:textSize="14sp" />

        <RatingBar
            android:id="@+id/searchRatingbar"
            style="?android:attr/ratingBarStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/txt_searchAutherName"
            android:layout_marginTop="12dp"
            android:layout_toRightOf="@+id/img_searchBookCoverPhoto"
            android:focusable="false"
            android:isIndicator="false"
            android:numStars="5"
            android:rating="5"
            android:stepSize="1" />
    </RelativeLayout>

</RelativeLayout>
  • My question is that i have a click event for Listview as shown below

enter image description here

but its not working, i m really amazed, why this is happening

As you can see that i have set this also

android:focusable="false"

for all view inside my custom listView.

here is code of custom adapter also.

public class BookSearchResultActivity extends Activity {

    static final String URL = "http://www.shiaislamiclibrary.com/requesthandler.ashx";
    static final String KEY_ITEM = "Book"; // parent node
    static final String KEY_BOOKAUTHOR = "BookAuthor";
    static final String KEY_BOOKTITLE = "BookTitle";
    static final String KEY_BOOKCODE = "BookCode";
    static final String KEY_BOOKIMAGE = "BookImage";

    ArrayList<String> BookTitle = new ArrayList<String>();
    ArrayList<String> BookCoverPhotos = new ArrayList<String>();
    ArrayList<String> BookAuther = new ArrayList<String>();
    ArrayList<String> ImageByte = new ArrayList<String>();
    ArrayList<Bitmap> bitmapArray = new ArrayList<Bitmap>();

    ListView lv;
    ListView listView;
    Activity act = this;

    LayoutInflater inflater = null;

    TextView txtSearchedKeywords;
    TextView txtSearchFor;
    TextView txtBooksCount;
    String keyWordsSearch;
    String language;

    URL bookImageURL = null;
    Bitmap bitMapImage = null;
    Context context = BookSearchResultActivity.this;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.book_search_layout);

        txtSearchedKeywords = (TextView) findViewById(R.id.txtKeyWordSearched);
        txtSearchFor = (TextView) findViewById(R.id.txtSearchFor);
        txtBooksCount = (TextView) findViewById(R.id.txtNmbrOfBooksFound);
        listView = (ListView) findViewById(R.id.searchList);

        Intent getInfoIntent = getIntent();
        keyWordsSearch = getInfoIntent.getStringExtra("SEARCH_KEYWORDS");
        language = getInfoIntent.getStringExtra("LANG");

        ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        // checking for availbe internet Connection
        if (cm.getActiveNetworkInfo() != null
                && cm.getActiveNetworkInfo().isAvailable()
                && cm.getActiveNetworkInfo().isConnected()) {

            new UIThread().execute(URL, keyWordsSearch, language);

        }

        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
                    long arg3) {
                Toast.makeText(context, BookTitle.get(pos).toString(),
                        Toast.LENGTH_SHORT).show();
            }
        });
    }

    private class UIThread extends AsyncTask<String, Integer, String> {

        ProgressDialog progressDialog;

        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub
            super.onPreExecute();
            progressDialog = ProgressDialog.show(getParent(),
                    "Search in Progress...",
                    "This may Take a few seconds.\nPlease Wait...");

            txtSearchFor.setText("Searching in Progress...!");
            txtBooksCount.setVisibility(View.INVISIBLE);

        }

        @Override
        protected String doInBackground(String... params) {

            String URL = params[0];
            String searchKeywords = params[1];

            XMLParser parser = new XMLParser();
            String XMLString = parser.getXmlFromUrl(URL, searchKeywords,
                    language);
            // Log.i("XML Response", XMLString);

            Document doc = parser.getDomElement(XMLString);

            NodeList nl = doc.getElementsByTagName(KEY_ITEM);

            // looping through all item nodes <item>
            for (int i = 0; i < nl.getLength(); i++) {
                Element e = (Element) nl.item(i);

                BookTitle.add(parser.getValue(e, KEY_BOOKTITLE));
                BookCoverPhotos.add("http://shiaislamicbooks.com/books_Snaps/"
                        + parser.getValue(e, KEY_BOOKCODE) + "/1_thumb.jpg");
                BookAuther.add(parser.getValue(e, KEY_BOOKAUTHOR));
                Log.i("URLs", BookCoverPhotos.toString());
            }
            for (int i = 0; i < BookAuther.size(); i++) {

                try {
                    bookImageURL = new URL(BookCoverPhotos.get(i));
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                    Log.i("URL", "ERROR at image position" + i + "");
                }

                try {
                    bitMapImage = BitmapFactory.decodeStream(bookImageURL
                            .openConnection().getInputStream());
                    bitmapArray.add(bitMapImage);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    Log.i("BITMAP", "ERROR" + i);
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);

            progressDialog.dismiss();
            txtSearchFor.setText("Results For");
            txtSearchedKeywords.setText("\"" + keyWordsSearch + "\"");
            txtBooksCount.setVisibility(View.VISIBLE);
            txtBooksCount.setText(bitmapArray.size() + " Book(s) found");
            ImageAdapter adapter = new ImageAdapter(getBaseContext(), act);
            listView.setAdapter(adapter);

        }

    }

    public class ImageAdapter extends BaseAdapter {

        public ImageAdapter(Context c) {
            context = c;
        }

        // ---returns the number of images---
        public int getCount() {
            return bitmapArray.size();
        }

        public ImageAdapter(Context ctx, Activity act) {
            inflater = (LayoutInflater) act
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }

        // ---returns the ID of an item---
        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        // ---returns an ImageView view---
        public View getView(int position, View convertView, ViewGroup parent) {

            // ImageView bmImage;

            final ViewHolder holder;
            View vi = convertView;
            if (convertView == null) {
                vi = inflater.inflate(R.layout.list_style, parent, false);
                holder = new ViewHolder();
                holder.txt_BooksTitle = (TextView) vi
                        .findViewById(R.id.txt_searchBookTitle);

                holder.img_BookCoverPhoto = (ImageView) vi
                        .findViewById(R.id.img_searchBookCoverPhoto);
                holder.txt_BooksAuthor = (TextView) vi
                        .findViewById(R.id.txt_searchAutherName);

                holder.ratingBar = (RatingBar) vi
                        .findViewById(R.id.searchRatingbar);

                vi.setTag(holder);
            } else {

                holder = (ViewHolder) vi.getTag();
            }
            holder.txt_BooksTitle.setText(BookTitle.get(position) + "");
            holder.img_BookCoverPhoto.setImageBitmap(bitmapArray.get(position));
            holder.txt_BooksAuthor.setText(BookAuther.get(position) + "");
            holder.ratingBar.setRating(3);
            return vi;
        }
    }

    class ViewHolder {
        TextView txt_BooksTitle;
        TextView txt_BooksAuthor;
        ImageView img_BookCoverPhoto;
        RatingBar ratingBar;
    }
}
  • 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-15T06:44:06+00:00Added an answer on June 15, 2026 at 6:44 am

    Please update below code of item_list.xml file, it will solve your problem.

    <?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="match_parent" >
    
        <RelativeLayout
            android:id="@+id/rel_SearchLayout01"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true" >
    
            <ImageView
                android:id="@+id/img_searchBookCoverPhoto"
                android:layout_width="70dp"
                android:layout_height="100dp"
                android:layout_margin="5dp"
                android:src="@drawable/ic_launcher" />
    
            <TextView
                android:id="@+id/txt_searchBookTitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/img_searchBookCoverPhoto"
                android:layout_marginTop="10dp"
                android:layout_toRightOf="@+id/img_searchBookCoverPhoto"
                android:text="The Basic Doctrine Of Islam"
                android:textSize="16sp" />
    
            <TextView
                android:id="@+id/txt_searchAutherName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/txt_searchBookTitle"
                android:layout_marginTop="2dp"
                android:layout_toRightOf="@+id/img_searchBookCoverPhoto"
                android:text="By: Andrew J Newman"
                android:textSize="14sp" />
    
            <RatingBar
                android:id="@+id/searchRatingbar"
                style="?android:attr/ratingBarStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/txt_searchAutherName"
                android:layout_marginTop="12dp"
                android:layout_toRightOf="@+id/img_searchBookCoverPhoto"
                android:numStars="5"
                android:rating="5"
                android:stepSize="1" />
        </RelativeLayout>
    
    </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have such a activity with my list: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have a custom drawable rounded_corner.xml: <?xml version=1.0 encoding=UTF-8?> <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle> <gradient android:startColor=#FFFFFF
I have created a custom listView with the row as follows: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have a custom ListView in which each row.xml looks like this: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I have done my custom ListView, the xml was following: <?xml version=1.0 encoding=utf-8?> <LinearLayout
I have a listView with custom objects defined by the xml-layout below. I want
I have a ListView that has a custom ArrayAdapter with a custom XML row.
I have one custom ListView called AreasListView which I've included in the XML file.
I have a custom listView. The main layout xml is something like this: <?xml
I have made custom .xml layout for ListView. Now it looks: But it isn't

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.