在微调器中将图像显示为项目

时间:2010-08-17 09:26:26

标签: android

我实现了对孩子们的应用程序我实现了spinner在添加的数组categeory列表这些是数组文本列表现在我实现这些文本数组列表替换在spinner中的drawable图像如何实现

personalinformation = (Spinner) findViewById(R.id.SpinnerCategory);
ArrayAdapter<?> adapterDefaultpersonal = ArrayAdapter.createFromResource(Animals.this,R.array.Animalinformation, android.R.layout.simple_spinner_item);
adapterDefaultpersonal.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
personalinformation.setAdapter(adapterDefaultpersonal);
personalinformation.setSelection( getSharedPreferences("", 0).getInt("SpinnerSelection", 0));
personalinformation.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> parent,View v,int position,long id)
{
if(position==0)
{
}});

this is the spinner code i am using array of text list these text replaced to drawable items in to spinner how can implemented some solution i am new in android

1 个答案:

答案 0 :(得分:0)

如果我正确理解了您的问题,您希望让微调器显示图标而不是文本。 然后,您需要扩展ArrayAdapter以覆盖getView()以返回imageView 有关详细信息,请查看this tutorial