这是我的代码。我想添加过滤器方法来搜索自定义适配器中的列表元素。我有很多示例代码,但是很难集成到我的代码中。
import java.util.ArrayList;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
class MyFSCustomAdapter extends BaseAdapter
{
String[] Name;
Bitmap[] data_imageID;
Context appcontext;
String []dist;
String []Address;
MyFSCustomAdapter()
{
}
MyFSCustomAdapter(String[] name, Bitmap[] imageID,String[] Dist,String[] Add, Context cont)
{
Name = name;
data_imageID = imageID;
dist=Dist;
Address=Add;
appcontext=cont;
}
MyFSCustomAdapter(ArrayList<String> name, ArrayList<Bitmap> image,ArrayList<String> Dist,ArrayList<String> Add)
{
Name = new String[name.size()];
data_imageID = new Bitmap[image.size()];
dist= new String[Dist.size()];
Address= new String[Add.size()];
for(int i=0;i<name.size();i++)
{
Name[i] = name.get(i);
data_imageID[i] = image.get(i);
dist[i]=Dist.get(i);
Address[i]=Add.get(i);
}
}
public int getCount()
{
return Name.length;
}
public String getItem(int position)
{
return null;
}
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater =(LayoutInflater) appcontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row=null;
row = inflater.inflate(R.layout.listview_fs, parent, false);
TextView txtName = (TextView) row.findViewById(R.id.Name);
TextView txtMetrs = (TextView) row.findViewById(R.id.meters);
TextView txtAddress = (TextView) row.findViewById(R.id.address);
final ImageView imageview = (ImageView) row.findViewById(R.id.ImageView01);
txtName.setText(Name[position]);
txtMetrs.setText(dist[position]);
txtAddress.setText(Address[position]);
imageview.setImageBitmap(data_imageID[position]);
return (row);
}
}
这是我的清单。请帮我....