Android的ArrayAdapter
1.用在 listView上
ArrayList<CharSequence> aBlogNames = new ArrayList<CharSequence>();
LayoutInflater inflater = (LayoutInflater)addAccount.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final ListView lv = (ListView) inflater.inflate(R.layout.select_blogs_list, null);
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
lv.setItemsCanFocus(false);
ArrayAdapter<CharSequence> blogs = new ArrayAdapter<CharSequence>(addAccount.this, R.layout.blogs_row, aBlogNames);
lv.setAdapter(blogs);
2.用在下拉框上
ArrayList<CharSequence> loadTextArray = new ArrayList<CharSequence>();
ArrayAdapter<CharSequence> categories = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_dropdown_item_1line, loadTextArray);
categories.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner sCategories = (Spinner) findViewById(R.id.parent_category);
sCategories.setAdapter(categories);
3.又一个下拉框的例子:
final Spinner sInterval = new Spinner(this);
sInterval.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
更多相关文章
- Login Reference for PhotoSomething
- Android消息机制之四---Looper,Handler,Message例子
- Android例子—设置Activity全屏的三种方法
- javaeye中的一些好的android博客
- Android(安卓)XML Shape使用入门
- android json解析及简单例子
- Android(安卓)5.0 android:elevation 如果给button设置效果
- android install faild insufficient storage错误的解决方法
- 如何导入android中的sample例子