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. Access assets from within ParcelFileDescriptor / ContentProvider

Hi together,

Since a few days we are struggling with accessing asset files. Pretty
early I found out that accessing assets is not directly possible with
the "file:///" Uri.
Now my colleague wrote a ContentProvider class.

Within the ParcelFileDescriptor from the ContentProvider we use the
openFile method to directly access a css file when the pfd is called
from within HTML with the content:// scheme.
Unfortunately, the css had no effect on the HTML and I found out with
File.exists() that this file does not exist under "file:///
android_asset/ + filename", although the file is obviously under
assets/Resources in my package exlplorer.

My presentiment is that it's all just a minor misuse of URI paths.

Thanks in Advance for any help.


Cheers,


Andre

--~--~---------~--~----~------------~-------~--~----~

2. SharedPreferences: editor.commit() always false even though it commits

Hi everyone,

Almost everything is in the title. I am trying to save username and
password into the sharedpreferences file. I used the little function
below to do so:
Everything works (The data are written correctly, I can read them
afterward) but the editor.commit() always returns false even though
the commit works(). Is that a bug?

        private void saveCredential(String username, String password)
        {
                // Restore or Create preferences if it doesn't exist
                SharedPreferences settings = 
getSharedPreferences(Common.PREFS_NAME,
MODE_PRIVATE);
                // We need an Editor object to make changes in the preferences 
file
                SharedPreferences.Editor editor = settings.edit();
                // Then we add the login and the password
                editor.putString(Common.PREF_USERNAME,username);
                editor.putString(Common.PREF_PASSWORD,password);
                // We don't forget to commit our edits
                if (editor.commit())
                         Log.v(DEBUG_TAG, "(Username: " + username + ") ;
(password : " + password + ") correctly added into file " +
Common.PREFS_NAME);
               else
                       // not good
        }

If anyone has a solution, an answer, anything, that would be great ;)

Also in term of security, is that fine? Should I store the credential
into a database or anything else?

Thanks a lot.
Polo

--~--~---------~--~----~------------~-------~--~----~

3. Application installing with default pre-made database file

4. location is always latitude 0 longitude 0 altitude 10 in v0.9

5. Task Manager, or something to close apps.

6. An Android wishlist from a soon-to-be-user

7. Possible to tie Alarm Clock to Calendar?