Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to filter data in custom list view
    primarykey
    data
    text
    <p>herein is my code</p> <pre><code>public class adapters extends Activity implements TextWatcher{ /** Called when the activity is first created. */ ListView lv1; e E; EditText e1; LinearLayout ll1; LinearLayout ll2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ll1.setBackgroundColor(color.transparent); e1=(EditText)findViewById(R.id.e1); lv1=(ListView)findViewById(R.id.lv1); ArrayList&lt;AdapterObject&gt; obj = new ArrayList&lt;AdapterObject&gt;(); AdapterObject adp; for(int i =0;i&lt;5;i++){ adp = new AdapterObject(); adp.setBmp(getResources().getDrawable(R.drawable.trees)); adp.setStr("Text "+String.valueOf(i)); obj.add(adp); } E = new e(this,2,obj); lv1.setAdapter(E); lv1.setTextFilterEnabled(true); e1.addTextChangedListener(this); } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub System.out.println(E.getItem(1)); E.getFilter().filter(e1.getText().toString(), new Filter.FilterListener() { @Override public void onFilterComplete(int count) { // TODO Auto-generated method stub System.out.println("tututututu"); E.notifyDataSetChanged(); }}); } } //here is the adapterobject class public class AdapterObject { Drawable bmp; String str; public Drawable getBmp() { return bmp; } public void setBmp(Drawable bmp) { this.bmp = bmp; } public String getStr() { return str; } public void setStr(String str) { this.str = str; } } //here is class e public class e extends ArrayAdapter&lt;AdapterObject&gt; { ArrayList&lt;AdapterObject&gt; Obj; Context mContext; public e(Context context, int textViewResourceId, ArrayList&lt;AdapterObject&gt; objects) { super(context, textViewResourceId, objects); mContext=context; Obj=objects; // TODO Auto-generated constructor stub } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub LayoutInflater l = (LayoutInflater) (mContext).getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = l.inflate(R.layout.new21, null); ImageView btn = (ImageView) v.findViewById(R.id.list_button); TextView text = (TextView)v.findViewById(R.id.list_text); btn.setBackgroundDrawable(Obj.get(position).getBmp()); text.setText(Obj.get(position).getStr()); System.out.println("here"); return v; } @Override public AdapterObject getItem(int position) { // TODO Auto-generated method stub return super.getItem(position); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload