概述
android filter
(2012-08-17 14:22:12)
转载▼
标签: 杂谈 |
一、何谓Android的过滤机制?
- public
static final class Location implements BaseColumns { -
public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "location" ); -
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/weather_location" ; -
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/weather_location" ; -
public static final String CONTENT_DIRECTORY = "location" ; -
-
public static final String LOCATION_NAME = "location_name" ; -
public static final String LONGITUDE = "longitude" ; -
public static final String ALTITUDE = "altitude" ; - }
- private
static class LocationAdapter extends CursorAdapter { -
private LayoutInflater mInflater; -
private Context mContext; -
private Cursor mCursor; -
public LocationAdapter(Context context, Cursor c) { -
super (context, c); -
mContext = context; -
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); -
} -
-
@Override -
public void bindView(View view, Context context, Cursor cursor) { -
TextView textView = (TextView) view; -
String location = cursor.getString(cursor.getColumnIndex(Location.LOCATION_NAME)); -
textView.setText(location); -
} -
-
@Override -
public View newView(Context context, Cursor cursor, ViewGroup parent) { -
return mInflater.inflate(android.R.layout.simple_dropdown_item_1line, null ); -
} -
-
@Override -
public Cursor runQueryOnBackgroundThre ad(CharSequence constraint) { -
String selection = Location.LOCATION_NAME + " LIKE '%" + constraint + "%'" ; -
return mContext.getContentResolver().query(Location.CONTENT_URI -
, null , selection, null , null ); -
} -
-
-
@Override -
public CharSequence convertToString(Cursor cursor) { -
return cursor.getString(cursor.getColumnIndex(Location.LOCATION_NAME)); -
} - }
- private
void initialTextView() { -
mTextView = new AutoCompleteTextView(mContext); -
mTextView.setThreshold(0 ); -
-
Cursor cursor = mContext.getContentResolver().query(Location.CONTENT_URI -
, null , null , null , null ); -
LocationAdapter adapter = new LocationAdapter(mContext, cursor); -
mTextView.setAdapter(adapter); - }
最后
以上就是辛勤草莓为你收集整理的android filter的全部内容,希望文章能够帮你解决android filter所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复