0
特定字母显示视图我有自定义适配器ListView和我创建使用矢量 我想只显示包含字母“A”,例如该国的TextView。 和我找不到解决方案来做到这一点。包含ListView中
这是我的适配器和我怎样努力去做
public class CountryAdapter extends BaseAdapter {
protected MainActivity main = new MainActivity();
private Context mContext;
protected Vector<Country> mVector;
protected SQLiteDatabase mDb;
Cursor cursor;
ImageView deleteIt;
View rowView;
public int pos;
public void setmContext(Context mContext) {
this.mContext = mContext;
}
public CountryAdapter(Context mContext) {
this.mContext = mContext;
mVector = new Vector<Country>();
CountryOpenHelper helper = new CountryOpenHelper(mContext);
mDb = helper.getWritableDatabase();
cursor = mDb.rawQuery("SELECT * FROM COUNTRIES", null);
if (cursor.getCount() > 0) {
cursor.moveToFirst();
}
do {
Country country = new Country();
country.setmCountryIndex(cursor.getInt(0));
country.setmCountryName(cursor.getString(2));
country.setmCountryTextSize(cursor.getInt(1));
country.setmCountryColor(cursor.getInt(3));
mVector.add(country);
for (int i = 0; i < cursor.getCount(); i++){
if (mVector.get(i).toString().contains("a") == false){
mVector.remove(i);
}
}
} while (cursor.moveToNext());
如果这里需要的是在我的CountryAdapter我GetView方法多数民众赞成在太:
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv;
if(convertView == null){
tv = new TextView(mContext);
}else{
tv = (TextView) convertView;
}
this.pos = position;
tv.setText(mVector.get(position).getmCountryName());
tv.setTextColor(mVector.get(position).getmCountryColor());
tv.setTextSize(mVector.get(position).getmCountryTextSize());
return tv;
}
我改成了mVector.size();仍然没有反应.. –