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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:55:54+00:00 2026-06-11T16:55:54+00:00

I am trying to create search activity. The layout contains EditText (to type search

  • 0

I am trying to create search activity. The layout contains EditText (to type search query) Button & ListView (to show search results). search_layout.xml (For showing searchbox & ListView) is as follow :

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

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/editText_search"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:hint="@string/search_practice" />

         <Button 
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/button_search"
             android:onClick="searchPractice" />

    </LinearLayout>

     <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <ListView 
            android:id="@+id/praclist"
            android:layout_weight="1"
            android:layout_width="fill_parent"            
            android:layout_height="fill_parent" />

    </LinearLayout>

</LinearLayout>

And layout for list items list_items.xml is :

<?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:orientation="horizontal">  
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <!-- Name Label -->
        <TextView
            android:id="@+id/name"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#43bd00"
            android:textSize="16sp"
            android:textStyle="bold"
            android:paddingTop="6dip"
            android:paddingBottom="2dip" />
        <!-- Description label -->
        <TextView
            android:id="@+id/city"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#acacac"
            android:paddingBottom="2dip">
        </TextView>
        <TextView
            android:id="@+id/email"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#acacac"
            android:paddingBottom="2dip">
        </TextView>
        <!-- Linear layout for cost and price Cost: Rs.100 -->
        <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <!-- Cost Label -->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#5d5d5d"
            android:gravity="left"
            android:textStyle="bold"
            android:text="Phone: " >
        </TextView>
        <!-- Price Label -->
        <TextView
            android:id="@+id/phone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#acacac" 
            android:textStyle="bold"
            android:gravity="left">
        </TextView>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

On button click (searchBtnClick) I am calling method doMySearch :

public void searchBtnClick(View view){
  -------
  ------
  ListAdapter adapter = doSearch(query);
  ListView pracListView = (ListView) findViewById(R.id.praclist);
  PracListView.setAdapter(adapter);
  return;
}

private ListAdapter doSearch(String query){
    ListAdapter adapter = null;
String url = "https://mywebservice.com/apps/api/v1/search/practices?val="+query+"&by=nam";

HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet(url);
String jsonResponsse = null;


try{
    HttpResponse httpResponse = httpClient.execute(httpGet, localContext);
    HttpEntity httpEntity = httpResponse.getEntity();
    jsonResponsse = getASCIIContentFromEntity(httpEntity);          
    Gson gson = new Gson();
    PracticesByName practicesByName = gson.fromJson(jsonResponsse,PracticesByName.class);
    ArrayList<Practices> practiceList = (ArrayList<Practices>)practicesByName.getPractices();
    for(int i=0 ; i < practiceList.size() ; i ++){   
        Object a = practiceList.get(i);
        System.out.println(a.getClass() + "   " + a.toString());
        Practices aPractice = practiceList.get(i);
        HashMap<String, String> aMap = new HashMap<String, String>();
        aMap.put(TAG_NAME, aPractice.getName());
        aMap.put(TAG_CITY, aPractice.getCity());
        aMap.put(TAG_EMAIL, aPractice.getEmail());
        aMap.put(TAG_PHONE, aPractice.getPhone());


        searchResultList.add(aMap);


    }


    adapter = new SimpleAdapter(this, searchResultList,
            R.layout.list_item_prac_search,
            new String[] { TAG_NAME, TAG_CITY, TAG_EMAIL, TAG_PHONE}, new int[] {
                    R.id.name, R.id.city, R.id.email, R.id.phone});
    //pracListView.setAdapter(adapter);


}catch (Exception e){
        System.out.println("Exception while getting serach for practice");
        e.printStackTrace();
}

return adapter;

}

The code is running fine. I am getting search result from web service. But don’t see any list below. Any idea what I am messing up?

  • 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-11T16:55:55+00:00Added an answer on June 11, 2026 at 4:55 pm

    Finally, Got it working. Corrected search_layout.xml as follow.

    <?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:orientation="vertical">
    
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal" >
    
            <EditText
                android:id="@+id/editText_search"
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:hint="@string/search_practice"
                android:imeOptions="actionDone" />
    
             <Button 
                 android:layout_width="wrap_content"
                 android:layout_height="fill_parent"
                 android:text="@string/button_search"
                 android:onClick="searchPractice" />         
        </LinearLayout>
    
        <ListView 
                android:id="@+id/praclist"
                android:layout_weight="1"
                android:layout_width="match_parent"            
                android:layout_height="wrap_content" />
    
    </LinearLayout>
    

    making outer layout vertical & placing horizontal layout (containing EditText & Search Button in it) and ListView in it.

    Thanks for your time.

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

Sidebar

Related Questions

I'm trying to create pagination for search results using MySQL and ColdFusion. My intention
I'm trying to create a search form that posts the results queried from a
I'm trying to create a search tool and would like to display the results
I am trying to create a search method to attach files on my outbound
I am trying to create a search page, this allows the admin to search
I am trying to create a quick search function on the menu of my
I'm trying to create a simple search field, what it does is it searches
I'm trying to create a simple search page, but I'm not 100% sure how
I'm trying to create a word search game (kind of like Wordament but much
I am trying to create a popup for a search box and submit the

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.