Filter for Custom ListView

by pawan nimje » Wed, 21 Apr 2010 05:05:25 GMT


Sponsored Links
 i,

I am having a custom listview [list with image and 2 textbox] and i
want to apply filter for it.

desc of cust listview:

1:Image i.e flag of country

2:1st textbox (name of country)

3:2nd textbox (name of continent)

so when i write " i " in a textbox [different from the ones mentioned
above] i want the list to get filtered according to country name.

My code details:

1:_________________________row.xml [each row of
list]__________________________

<?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="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dip"/>
<!-- android:src="@drawable/icon" />-->
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="35dip">
<TextView
android:id="@+id/toptext"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center_vertical"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:id="@+id/bottomtext"
android:singleLine="true"
android:ellipsize="marquee"
/>
</LinearLayout>
</LinearLayout>

2:__________________main.xml_____________________

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText android:id="@+id/search_box"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="type to filter"
android:inputType="text"
android:maxLines="1"/>
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView
android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/main_no_items"/>
</LinearLayout>

3:_______________________softwarepassionview.java___________________________
package com.softberries.lve;

import java.util.ArrayList;

//import com.TryFilter.R;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;



Other Threads

1. Detecting slow or unavailable network and black screen

My application for the most part prefers to be online, I have of
course added an offline mode so that it works perfectly well when not
attached and then re-syncs when connected again.  I do, however, have
an issue with the initial start of the main activity "black screening"
on me while (i assume) it is waiting on a TCP timeout.  It would be
nice to query and skip the download step if the network is super slow.

Here is pseudo code for what I am doing:

public void OnCreate(...) {
   if( !loggedin )
       showLoginActivity()
   else {
      new downloadData().doInBackground();
      showDataList(m_datalist );  //keep in mind that m_datalist is
displayable
   }
}

public class downloadData extends AsyncTask<String, Integer, Integer>
{
 protected Integer doInBackground(Integer... params) {
     //http get of JSON data
    m_datalist = getJSONDataFromServer();
 }
}

The showDataList function creates rows in my list and populates the
list from the content in m_datalist which has the last valid dataset
in it at all times.  The issue is that it just black screens while
downloading data even though I have it getting this data in an
AsyncTask.

The preferred experience would be for the application to draw the list
and be usable while the download thread retrieves any new
information.  This then gets to my question, if I could detect a slow
or unresponsive internet connection I could possibly skip the HTTP
calls until a time where the internet was more healthy.

Ideas?

--G

-- 

2. Yahoo messenger update 1.0.2

Barusan dapat notifikasi update 1.0.2 keliatanya ada perbedaan

Silahkan di market

---------frf91---------

-- 
"Indonesian Android Community [id-android]" 

3. Spinners identical in XML but look different when run

4. servicemanager crashing repeatedly

5. Medium density resources for v1.5 problems with workaround

6. Video playback fails when played from 3DGallery in Froyo

7. R: Strange behavior of the panel for developers of Android Market.