Android 如何自定义微调器适配器
Android 如何自定义微调器适配器,android,Android,我正在写一个Android应用程序,我需要在左边显示一个下拉列表,而不是普通微调器控件中的RadioButton。我想自定义微调器控件。在Android中定制Spinner需要遵循哪些步骤。 有谁能给我提供整理这个问题的示例代码吗? 我将等待有价值的答复 提前感谢,微调器弹出项完全可自定义。扩展ArrayAdapter并重写getDropDownView方法。为每个项目调用此方法。这里的T类型是您为适配器提供的任何类型 /** Expands the view and setup with th
我正在写一个Android应用程序,我需要在左边显示一个下拉列表,而不是普通微调器控件中的RadioButton。我想自定义微调器控件。在Android中定制Spinner需要遵循哪些步骤。 有谁能给我提供整理这个问题的示例代码吗?
我将等待有价值的答复
提前感谢,微调器弹出项完全可自定义。扩展ArrayAdapter并重写getDropDownView方法。为每个项目调用此方法。这里的T类型是您为适配器提供的任何类型
/** Expands the view and setup with the view for each item in spinner popup **/
@Override
public View getDropDownView(int position, View view, ViewGroup parent) {
T choice = getItem(position);
if (view == null) {
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// expand your list item here
view = vi.inflate(R.layout.mylistitem, null);
}
if(choice != null) {
// get whatever items are in your view
TextView text = (TextView) view.findViewById(R.id.text);
ImageView left = (ImageView) view.findViewById(R.id.leftImage);
// do whatever you want with your item view
}
return(view);
}
重写适配器的getView以设置主微调器控件的视图。您可以一次调用另一次,使选择和弹出窗口具有相同的外观。微调器弹出窗口项目完全可自定义。扩展ArrayAdapter并重写getDropDownView方法。为每个项目调用此方法。这里的T类型是您为适配器提供的任何类型
/** Expands the view and setup with the view for each item in spinner popup **/
@Override
public View getDropDownView(int position, View view, ViewGroup parent) {
T choice = getItem(position);
if (view == null) {
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// expand your list item here
view = vi.inflate(R.layout.mylistitem, null);
}
if(choice != null) {
// get whatever items are in your view
TextView text = (TextView) view.findViewById(R.id.text);
ImageView left = (ImageView) view.findViewById(R.id.leftImage);
// do whatever you want with your item view
}
return(view);
}
重写适配器的getView以设置主微调器控件的视图。您可以让一个呼叫另一个,使选择和弹出窗口具有相同的外观。您好,没有人在这个问题上提供帮助吗?您可以添加一些屏幕截图或更详细的目标吗?应该是下拉列表视图。通常情况下,ListView不会有任何单选按钮。我只希望文本以下拉列表的形式显示,不带spinnerhi默认的单选按钮。在这个问题上没有人可以提供帮助?您可以添加一些屏幕截图或更详细的目标吗?应该是下拉ListView。通常对于ListView不会有任何单选按钮。我只希望文本以下拉列表的形式显示,不带spinner默认附带的out单选按钮