Fwd: Filter for Custom ListView

by pawan nimje » Wed, 21 Apr 2010 18:14:48 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;
import android.view.LayoutInflater;
import a



Other Threads

1. onContextItemSelected is not working; window already focused warning message

Hello,


I have 2 classes that each have listview. I want both of these
listviews to access the same context menu, so I'm making a context
menu in a separate class.
Right now I only work with one of the class (that has listview) to see
if this can work. But apparently it can not. When I click and held the
listview, the context menu pops up. However, if I choose one of the
option nothing happened. It seems like the program never reach the
onContextItemSelected. I  tried to debug it and see what happens, and
I get this message (whenever I clicked the contextmenu options) :

Window already focused, ignoring focus gain of:
com.android.internal.view.iinputmethodclient$stub$pr...@43c488f8

This is what I put in the class that has listview:

//    ContextMenuClass makemenu = new ContextMenuClass();
//    makemenu.menuFunction(mylistview);


And this is the ContextMenuClass i.e. the class that has contextmenu:

===ContextMenuClass.java===

public class ContextMenuClass extends Activity{
    public void menuFunction(ListView listview) {
        registerForContextMenu(listview);
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo){
        super.onCreateContextMenu(menu, v, menuInfo);
        AdapterView.AdapterContextMenuInfo info =
            (AdapterView.AdapterContextMenuInfo)menuInfo;
        Log.d("Test", "oncreatecontextmenu is working");
        menu.setHeaderTitle("Listview Number " + info.position);
        menu.add(0, 1, 0, "OPTION_1");
    }

    @Override
    public boolean onContextItemSelected (MenuItem item) {
        Log.d("Test", "oncontextitemselected is working");
        switch (item.getItemId()){
            case 1:
                Toast.makeText(this, "This is Option 1",
Toast.LENGTH_SHORT).show();
                return true;
        }
        Log.d("Test", "return default");
        return super.onContextItemSelected(item);
    } }

=====================================================


Is separating onCreateContextMenu and onContextItemSelected from the
listview is the problem itself, or the problem comes from another
thing?
Any help will be much appreciated.

Thanks.



      

-- 

2. Setting up command line development on Ubuntu

I'm trying to be able to create a simple application for a Motorola
Droid using the command line in Ubuntu 9.04.
I've tried eclipse, but the C++, PHP, Android, etc parts seem to be
incompatible and cause eclipse to not run very well, so I've abandoned
eclipse on Ubuntu. I'm trying to set up the tools on the command line.

Here's what I've done so far:

   1. download  android-sdk_r05-linux_86.tgz  from
http://developer.android.com/sdk/index.html
   2. tar xvzf android-sdk_r05-linux_86.tgz
   3. ln -s android-sdk-linux_86 android
   4. in .tcshrc added  setenv PATH .....:/home/xxx/android/tools
   5. source .tcshrc
   6. ran 'android'. This opened a gui. I selected 'available
packages' and installed everything, and quit the gui.
   7. ran 'android list targets' and I get:

Available Android targets:
id: 1 or "android-3"
     Name: Android 1.5
     Type: Platform
     API level: 3
     Revision: 1
     Skins: HVGA-P, HVGA (default), QVGA-P, QVGA-L, HVGA-L
id: 2 or "Google Inc.:Google APIs:3"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 3
     Description: Android + Google APIs
     Based on Android 1.5 (API level 3)
     Libraries:
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: QVGA-P, HVGA-L, HVGA (default), QVGA-L, HVGA-P
id: 3 or "android-4"
     Name: Android 1.6
     Type: Platform
     API level: 4
     Revision: 1
     Skins: HVGA (default), WVGA800, WVGA854, QVGA
id: 4 or "Google Inc.:Google APIs:4"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 2
     Description: Android + Google APIs
     Based on Android 1.6 (API level 4)
     Libraries:
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: WVGA854, HVGA (default), QVGA, WVGA800
id: 5 or "android-6"
     Name: Android 2.0.1
     Type: Platform
     API level: 6
     Revision: 1
     Skins: WQVGA432, HVGA (default), WVGA800, WVGA854, WQVGA400, QVGA
id: 6 or "Google Inc.:Google APIs:6"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 1
     Description: Android + Google APIs
     Based on Android 2.0.1 (API level 6)
     Libraries:
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: WQVGA400, WVGA854, HVGA (default), WQVGA432, QVGA, WVGA800
id: 7 or "android-7"
     Name: Android 2.1
     Type: Platform
     API level: 7
     Revision: 1
     Skins: WQVGA432, HVGA (default), WVGA800, WVGA854, WQVGA400, QVGA
id: 8 or "Google Inc.:Google APIs:7"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 1
     Description: Android + Google APIs
     Based on Android 2.1 (API level 7)
     Libraries:
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: WQVGA400, WVGA854, HVGA (default), WQVGA432, QVGA, WVGA800



I think that I next need to run something like 'android create avd --
target 2 --name my_avd', but not sure.
If I run 'android' by itself it says that there are no 'Virtual
Devices', even though 'android list targets' lists 8 targets.

1. Is a target the sams as a Virtual Device? If so, why don't they
show up in the gui program?
2. How do I see what the skins look like?
3. Which skin should I use for the Motorola Droid? Or where can I get
a target/virtual device/skin for the droid?

thanks,
Bob

-- 

3. Rating Bar Stars cutoff in Droid

4. Ada yang tau Tutorial APP2SD di HTC Magic 32A ga?HELP...

5. Configuring the icons of an ExpandableListView - A simple example

6. ADO.NET like database interface

7. Override default icons of BaseExpandableListAdapter