在listview中搜索(自定义适配器)

时间:2016-01-28 20:00:06

标签: android listview

我想在我的Listview中实现搜索,我尝试了很多,但我没有找到任何使用我的代码的soluzine! 你能帮助我吗?或者在案例中向我展示替代方法? 谢谢你的帮助!

public class CustomListAdapter extends ArrayAdapter<String> {

private final Activity context;
private final String[] itemname;

private String[] url;

public CustomListAdapter(Activity context, int mylist, String[] itemname, String[] url) {
    super(context, R.layout.mylist, itemname);
    // TODO Auto-generated constructor stub

    this.context=context;
    this.itemname=itemname;
    this.url= url;

}

public View getView(int position,View view,ViewGroup parent) {
    LayoutInflater inflater=context.getLayoutInflater();
    View rowView=inflater.inflate(R.layout.mylist, null,true);

    TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
    ImageView image = (ImageView) rowView.findViewById(R.id.icon);
    TextView extratxt = (TextView) rowView.findViewById(R.id.textView1);

    txtTitle.setText(itemname[position]);

    extratxt.setText("Ricetta " + itemname[position]);

    Picasso
            .with(context)
            .load(url[position])
            .fit() // will explain later
            .transform(new RoundedTransformation(5, 0))
            .centerCrop()
            .into(image);

   return rowView;

   };

}

我不能把主要活动

0 个答案:

没有答案