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. How to connect to a binder c++ service?

Hello,

I want to create a binder service in C++ and be able to bind to that
service from java. My question is how? I have mimicked the
implementation in frameworks/base/camera/tests/CameraServiceTest/
CameraServiceTest.cpp. It compiles nicely without any warnings and I
can run it. But how do I connect to it?

The code for the service is here:

------------------------------------------------------------------------------------------------------------------------------------------
/* Imitating frameworks/base/camera/tests/CameraServiceTest/
CameraServiceTest.cpp */

#include <binder/IInterface.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include <binder/IBinder.h>

using namespace android;


class IPokeService : public IInterface {
        protected:
                enum {
                        POKE = IBinder::FIRST_CALL_TRANSACTION
                };

        public:
                DECLARE_META_INTERFACE(PokeService);
                virtual void poke() = 0;
};

class BnPokeService : public BnInterface<IPokeService> {
        virtual status_t onTransact(uint32_t code, const Parcel& data,
Parcel* reply, uint32_t flags = 0);
};

class BpPokeService : public BpInterface<IPokeService> {
        public:
                BpPokeService(const sp<IBinder>& impl) :
BpInterface<IPokeService>(impl) {
                }

                virtual void poke() {
                        Parcel data, reply;
                        remote()->transact(POKE, data, &reply);
                }
};

IMPLEMENT_META_INTERFACE(PokeService, "PokeService");

status_t BnPokeService::onTransact(uint32_t code, const Parcel& data,
Parcel* reply, uint32_t flags) {
        switch(code) {
                case POKE: {
                          poke();
                          return NO_ERROR;
                } break;
                default:
                        return BBinder::onTransact(code, data, reply, flags);
        }
}

class PokeService : public BnPokeService {
        virtual void poke() {
                printf("Poked\n");
        }
};

int main(int argc, char **argv)
{
        defaultServiceManager()->addService(String16("PokeService"), new
PokeService());
        ProcessState::self()->startThreadPool();

        android::ProcessState::self()->startThreadPool();
        LOGI("Poke service is now ready");
        IPCThreadState::self()->joinThreadPool();

        return 0;
}
------------------------------------------------------------------------------------------------------------------------------------------

And here is my Android.mk
------------------------------------------------------------------------------------------------------------------------------------------
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := main.cpp

LOCAL_CFLAGS += -DPLATFORM_ANDROID

LOCAL_MODULE := poke

# for now, until I do a full rebuild.
LOCAL_PRELINK_MODULE := false

LOCAL_SHARED_LIBRARIES += liblog
LOCAL_SHARED_LIBRARIES += libutils libui libcutils
LOCAL_SHARED_LIBRARIES += libbinder

include $(BUILD_EXECUTABLE)
------------------------------------------------------------------------------------------------------------------------------------------


The service won't show up when I do a listing in java:

------------------------------------------------------------------------------------------------------------------------------------------
Context context = getBaseContext();
ActivityManager am = (ActivityManager)
context.getSystemService(Activity.ACTIVITY_SERVICE);

List<RunningServiceInfo> serviceInfos = am.getRunningServices(50);

for (RunningServiceInfo service : serviceInfos) {
        Log.i("Service", "Process " + service.process + " with component " +
service.service.getClassName());
}
------------------------------------------------------------------------------------------------------------------------------------------

That will only give me from logcat:
I/Service (  715): Process system with component
com.android.internal.service.wallpaper.ImageWallpaper
I/Service (  715): Process com.android.phone with component
com.android.phone.BluetoothHeadsetService
I/Service (  715): Process com.android.inputmethod.latin with
component com.android.inputmethod.latin.LatinIME

Any help would be appreciated!

Kind regards,
Samuel



-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. Setting the font of a WebView

I have my own font TTF files, and want to use them in a WebView.

Is this possible?

-- 

3. "init" fail to start several services

4. Changelog in Market!

5. VerifyError: arbitrarily rejecting large method

6. ALSA AUDIO on PXA3xx

7. Fwd: Not getting expected socket errors