Hallo,
ich brauche für meine Custom Listview eine searchbox also sowas wie hier:
Die Beispiele die ich im Netzt gefunden haben, waren meist für normale Fieldlists oder sehr speziell auf ein Beispiel beschränkt, so das ich die nich adaptieren konnte.
Die activity sieht so aus:
und die Layout Datei so:
Wäre für jede Hilfe dankbar.
ich brauche für meine Custom Listview eine searchbox also sowas wie hier:
Die Beispiele die ich im Netzt gefunden haben, waren meist für normale Fieldlists oder sehr speziell auf ein Beispiel beschränkt, so das ich die nich adaptieren konnte.
Die activity sieht so aus:
Java:
package de.bodprod.rettinfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class AntidotList extends Activity{
ArrayList<HashMap<String, String>> antidotList;
String[] sqliteIds;
public static String TAG_ID = "id";
public static String TAG_TOX = "tox";
public static String TAG_ANTIDOT = "antidot";
ListView lv;
int textlength=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.antidotlist_layout);
antidotList = new ArrayList<HashMap<String, String>>();
lv = (ListView) findViewById(R.id.antidotlistlayout);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
new loadStoreAntidots().execute();
}
class loadStoreAntidots extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... args) {
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
DatabaseHandler db = new DatabaseHandler(getApplicationContext());
List<AntidotsClass> antidots = db.getAllAntidots();
sqliteIds = new String[antidots.size()];
for (int i = 0; i < antidots.size(); i++) {
AntidotsClass s = antidots.get(i);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_ID, s.getId().toString());
map.put(TAG_TOX, s.getTox());
map.put(TAG_ANTIDOT, s.getAntidot());
// adding HashList to ArrayList
antidotList.add(map);
// add sqlite id to array
// used when deleting a website from sqlite
sqliteIds[i] = s.getId().toString();
}
ListAdapter adapter = new SimpleAdapter(
AntidotList.this,
antidotList, R.layout.antidotlistitem_layout,
new String[] { TAG_ID, TAG_TOX, TAG_ANTIDOT },
new int[] { R.id.sqlite_id, R.id.tox_layout, R.id.antidot_layout }
);
lv.setAdapter(adapter);
}
});
return null;
}
}
}
und die Layout Datei so:
Code:
<?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="fill_parent"
style="@style/mainView"
android:orientation="vertical" >
<EditText android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="Suchen">
</EditText>
<ListView
android:id="@+id/antidotlistlayout"
style="@style/mainView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Wäre für jede Hilfe dankbar.